Hi All, I have array of objects in each document in index. I want to group by
and retrieve stats based on fields from this array. But stats is calculated
based on sum of all values in this array. Could you please suggest, is there
mistake in my query or expected behavior for now?Example of my document:{  
"city":"London",   "arrayField":[      {         "groupByField":"value1",       
 
"statsField":10      },      {         "groupByField":"value1",        
"statsField":20      },      {         "groupByField":"value2",        
"statsField":10      },      {         "groupByField":"value2",        
"statsField":5      }   ]}Example of my query:{  "size" : 0,  "aggregations"
: {    "filter" : {      "filter" : {        "bool" : {          "must" : {     
      
"match_all" : { }          }        }      },      "aggregations" : {       
"terms" : {          "terms" : {            "field" :
"arrayField.groupByField",            "size" : 100000          },         
"aggregations" : {            "districts.population" : {             
"stats" : {                "field" : "arrayField.statsField"              }     
      
}          }        }      }    }  }}I expect to get results:for group1: sum
= 30for group2:sum = 15I actually get: for group1:sum = 45for group2:sum =
45



--
View this message in context: 
http://elasticsearch-users.115913.n3.nabble.com/Inconsistent-results-when-aggregate-by-field-from-array-tp4072818.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/1427707127194-4072818.post%40n3.nabble.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to