You can also compare two values in the execution context by specifying the compared value as a path of the form of {{path}} . For example, the following condition compares the ctx.payload.aggregations.status.buckets.error.doc_count to the ctx.payload.aggregations.handled.buckets.true.doc_count :
It's much better to ditch the compare condition here and go with the script condition if you want to compare to response values of the a search input.
Also note that the paths you are referring to, do not match with your configured chain input. The names of the the inputs are first and second respectively, which can be anything, but those names need to be used to refer to them.
In addition, the output of an aggregation includes an array of buckets, so you cannot directly address the keys. The example below checks if the first two buckets are equal - this may or may not be what you are after.
If you take a step back and explain your use case a bit more detailed (without any mention of Elasticsearch, just the problem you are trying to solve), we might come with a completely different solution than this one, as I am not sure it fits every case (like comparing only the first output of the aggregation buckets).
I have only one index and i want to compare two fields value and get the result, they are the same fields but may have different values from different requests.
I wanna compare them and check if they have the same value, I would receive an e-mail showing me the requests.
For example: If the values of the field host are the same, then a message would be logged
Index: index-*
fields: 1. host:star
2. port:1221
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.