I want to build a query to get the price from the latest document (time). And within the query, there can be other aggregations like “avg”.
The query will be like:
"query" : {
// some filters
"aggregations" : {
"AVG_price” : {
"avg" : {
"field" : “price”
}
},
"LAST_price” : {
// get the price from the latest, i.e, "price" from the doc of max(“time”); how??
}
// snip
Documents have fields like:
“price” : 100
“time” (epoch) : 1531332965000
What will be the best way to have “Last_price”?
We are using Elasitcsearch 5.6.4.
Thanks in advance.
Top_hits works for me; even though I need to work on different result output formats the performance is so much better than using scripts.
Thanks much!!
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.