I have sub documents in the main document , below is the format:
"activities:[
{
"code": "CODE1",
"price":20
},
{
"code": "CODE2",
"price":24
}
]
I want to sum the price group by code. However, the term aggregates query give result for CODE1:44 instead 20. because the sum aggs is sum up the price field for all inner documents.
Thanks @dadoonet . nested aggregation is the solution. Because the nested aggregation treats the sub documents as main document. This may be the reason.
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.