I have 2 indices and they store data of the same mappings on different dates - t1 and t2.
I have a multi term aggregation below which works on a single index. How can I get elasticsearch to return the same aggregation across t1 and t2 as well as do some comparison like t1.total-price - t2.total-price?
Yes I got that. I am able to get t1 and t2 returned together but I am not sure how I can calculate the difference between aggregated results across the 2 indices. Any ideas on that?
Hi ice2021,
it is perfectly doable with a Bucket script aggregation | Elasticsearch Guide [7.12] | Elastic
The tricky part is the bucket path: follow the link in the mentioned doc to "bucket path syntax".
Tip: the account should be your top aggregation. Then, for each account you can aggregate by index, and get the sum of prices. your final bucket-script-aggregation will just substract the 2 sums, using bucket paths which contain the index names (that you should know).
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.