I have the following nested mapping for the data.
{
"index": {
"mappings": {
"type": {
"_all": {
"enabled": false
},
"properties": {
"A": {
"type": "nested",
"properties": {
"productmaster_FABRIC": {
"type": "string",
"index": "not_analyzed",
"fielddata": {
"format": "doc_values",
"loading": "eager_global_ordinals"
},
"fields": {
"hash": {
"type": "murmur3",
"precision_step": 2147483647
}
},
"null_value": "null",
"ignore_above": 10922
}
}
},
"purchaseli_QTY": {
"type": "integer"
}
}
}
}
}
}
sample data for the object is
[{purchaseli_QTY : 1, productmaster_FABRIC:"cotton"},{purchaseli_QTY : 2, productmaster_FABRIC:"polyster"}, {purchaseli_QTY : 1, productmaster_FABRIC:"rymonds"},
{purchaseli_QTY : 8, productmaster_FABRIC:""},{purchaseli_QTY : 5, productmaster_FABRIC:"cotton"},{purchaseli_QTY : 2, productmaster_FABRIC:"polyster"}, {purchaseli_QTY : 5, productmaster_FABRIC:"rymonds"},
{purchaseli_QTY : 9, productmaster_FABRIC:""},{purchaseli_QTY : 1, productmaster_FABRIC:"cotton"},{purchaseli_QTY : 2, productmaster_FABRIC:"polyster"}, {purchaseli_QTY : 1, productmaster_FABRIC:"rymonds"},
{purchaseli_QTY : 8, productmaster_FABRIC:""},{purchaseli_QTY : 1, productmaster_FABRIC:"cotton"},{purchaseli_QTY : 2, productmaster_FABRIC:"polyster"}, {purchaseli_QTY : 1, productmaster_FABRIC:"rymonds"},
{purchaseli_QTY : 8, productmaster_FABRIC:""}]
here is my query with the sum, avg or any other aggregation would return the wrong results for the empty field, other than the count aggregation.
{
"size": 0,
"_source": false,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [{
"query": {
"nested": {
"path": "A",
"query": {
"term": {
"A.productmaster_FABRIC": ""
}
}
}
}
}]
}
}
}
},
"aggs": {
"sumpurchase": {
"sum": {
"field": "purchaseli_QTY"
}
}
}
}
is any one has any idea about this issue.
I am using the elasticsearch 2.2.0 version.