Hi everyone,
I hope you are doing well.
I am doing a REST call directly to elasticsearch 7. To filter the results (by action, espace_name, username and timestamp), I need to send a body like this one :
{"from": 0, "size": 200, "sort" : { "Instant" : "desc" }, "query": { "bool": { "must": [ { "match": { "Action":"GetList" }}, { "match": { "Espace_Name":"Tarefas" }},
{ "match": { "Username":"P02154" }},
{"range" : { "Instant" : { "gte" : "2019-11-14T14:09:00.476565Z", "lte" : "2019-11-14T14:10:00.758346Z" } } } ] }}}
However, because the "match" attributes are changing dynamically, according to the filter I want to implement, I am having some troubles building a compatible structure.
Can someone give me an idea how to solve this issue?
Thank you.
Hello Joana,
You can create a local object, after that you manipulate your object/list, and after you must convert in JSON.
Example:
Regards.
Hi Agno,
I am already doing a serialization.
The problem is that I cannot build a structure that meets the requirements because "match" attribute depends on the filter and I cannot have two different attributes with the same name in JSON.
Your best bet is the ArdoJson Forge component:
See the example below.
I'm not sure if I got the JSON Path correct - you'll probably need to play around with an online evaluator to get it right.