I'm trying to run a term_stats facet to calculate some values with a
grouping, but am curious why the values returned don't add to what I
expect....I might be missing something on how the term_stats is suppose to
work.
Here's my query:
curl -s -XGET 'http://localhost:9200/my_index/my_type/_search?pretty=true'
-d '
{
"query": {
"filtered": {
"query": {
"bool" : {
"must" : { "field" : { "campaign_group_id" : 187 } },
"must" : { "field" : { "optimizer_id" : 79 } },
"must" : { "field" : { "keyword_id" : 638489 } }
}
},
"filter": {
"numeric_range": { "dw_date_marker_id": { "from": 1022, "to":
1022,"include_lower" : true,"include_upper":true } }
}
}
},
"facets" : {
"actual_click_cost_last_24_hours_stats" : {
"terms_stats" : {
"key_field" : "keyword_id",
"value_field" : "actual_click_cost_last_24_hours"
}
}
}
}'
I have two records that meet the filter criteria. The two values for
the actual_click_cost_last_24_hours in the documents are as follows:
doc1:
actual_click_cost_last_24_hours: 2.54
doc2:
actual_click_cost_last_24_hours: 1.75
When I run the query, these are the results of the facet:
.....
.....
"facets" : {
"actual_click_cost_last_24_hours_stats" : {
"_type" : "terms_stats",
"missing" : 0,
"terms" : [ {
"term" : 638489,
"count" : 2,
"total_count" : 2,
"min" : 1.0,
"max" : 2.0,
"total" : 3.0,
"mean" : 1.5
} ]
}
}
}
Why wouldn't the total be 2.54+1.75=4.29 vs 3.0? it seems that the .54 and
.75 are being lost.....how can if prevent the rounding?
Regards,
Dan