Value of above needs to be return in
{
"query": {"match": {"id": <max_id>}}
}
Or is there any way where i can create nest query as below
{
"query": {"match": { "id":
{
"aggs" : {
"max_id" : { "max" : { "field" : "id" } }
}
}
}
}
}
can you explain what you are after? Would it be sufficient to have have a query, which sorts by the id field and has a size of 1? This way there would not be a need to use aggs at all.
Hi Alex,
Thanks for the reply.
But my problem is i am using this query in watcher so whatever condition or query i will be using will be in one single block.
now we're getting somewhere it always makes sense to post your full problem initially so it is easier to come up with solutions.
Luckily you can solve this with watcher. Just use the chain input to the max value first, then you can use a chain transform to extract the max value and then use a search input with that extracted value - you can use the template syntax and access the transformed field like ctx.payload.second.path (from the example in the docs).
Hi Alex,
Thanks for the Solution,
do you have any live example of this type so i can get brief idea , what to be done.
or you can even modify the above code,so i can get idea how it will look like.
the best way would be get started with the chain input from the docs and go from there. If you have problems, please show exactly what they are including the output of the execute watch api, that usually helps a lot to debug.
Hi Alex ,
I used the Chain input For max operation but it gives me 500 internal error.
Add to a point that the watcher i am using is in sentinl (open source).
Please suggest , below is the code:
please take the time to properly format your code. You can use markdown in here, it will make it a million times easier to read a snippet.
Also, the blog post above included some tricks like the execute watch api, which should be used. This way you can also include the output here to ease debugging and see where the problem actually is, instead of just pasting your input snippet here, again debugging will become much simpler when also seeing the output.
Error: save watcher : save watcher : index watcher : mapping set to strict, dynamic introduction of [Input] within [sentinl-watcher] is not allowed: [strict_dynamic_mapping_exception] mapping set to strict, dynamic introduction of [Input] within [sentinl-watcher] is not allowed.
I'm confused now, what exactly sentinl watcher is. I suppose this some solution not by elastic (please correct me if I am wrong), so you might be better off, asking in the respective support forums about it.
Hi Alex,
Thanks for suggestions you provided till now,
Atlast i have used {{payload.aggregations.max_instance_id.value}} in email body and it does print the perfect value in email.
So is there any way, where i can put if condition in below loop
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.