Getting different doc count for the same nested aggregation

Below is my aggregation

"aggregations": {
"dealsMappedCatNested": {
"nested": {
"path": "deals"
},
"aggregations": {
"dealsMappedCatFilter": {
"filter": {
"bool": {
"filter": [{
"exists":{
"field":"deals.dealId"
}
},
{
"term": {
"deals.categoryId": {
"value": "SNM",
"boost": 1
}
}
},
{
"term": {
"deals.state": {
"value": "live",
"boost": 1
}
}
},
{
"term": {
"deals.isSoldOut": {
"value": false,
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"aggregations": {
"mappedCatNested": {
"nested": {
"path": "deals.mappedCategories"
},
"aggregations": {
"mappedCatTerm": {
"terms": {
"field": "deals.mappedCategories._id",
"size": 10,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
]
}
}
}
}
}
}
}
}
}

Results

"dealsMappedCatNested": {
"doc_count": 749,
"dealsMappedCatFilter": {
"doc_count": 486,
"mappedCatNested": {
"doc_count": 1446,
"mappedCatTerm": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 3,
"buckets": [
{
"key": "20",
"doc_count": 159
},
{
"key": "573acfce13db210aba60ccc5",
"doc_count": 118
},
{
"key": "573ad08313db210aba60ccc7",
"doc_count": 103
},
{
"key": "573ad08313db210aba60ccc8",
"doc_count": 29
},
{
"key": "573ad08313db210aba60ccc9",
"doc_count": 25
},
{
"key": "573acfce13db210aba60ccc6",
"doc_count": 22
},
{
"key": "573ad08313db210aba60ccca",
"doc_count": 21
},
{
"key": "573ad08313db210aba60cccb",
"doc_count": 19
},
{
"key": "573ad08313db210aba60cccd",
"doc_count": 6
},
{
"key": "573ad08313db210aba60cccc",
"doc_count": 5
}
]
}
}
}
}

"dealsMappedCatNested": {
"doc_count": 749,
"dealsMappedCatFilter": {
"doc_count": 486,
"mappedCatNested": {
"doc_count": 1446,
"mappedCatTerm": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 6,
"buckets": [
{
"key": "20",
"doc_count": 185
},
{
"key": "573acfce13db210aba60ccc5",
"doc_count": 131
},
{
"key": "573ad08313db210aba60ccc7",
"doc_count": 115
},
{
"key": "573acfce13db210aba60ccc6",
"doc_count": 28
},
{
"key": "573ad08313db210aba60cccb",
"doc_count": 28
},
{
"key": "573ad08313db210aba60ccc8",
"doc_count": 26
},
{
"key": "573ad08313db210aba60ccc9",
"doc_count": 23
},
{
"key": "573ad08313db210aba60ccca",
"doc_count": 20
},
{
"key": "573ad08313db210aba60ccce",
"doc_count": 9
},
{
"key": "573ad08313db210aba60cccd",
"doc_count": 8
}
]
}
}
}
}

I think its related to the merging of results on the coordinating node.But it is creating issue with the final output for my application which is displayed to user.Can anyone tell how can i solve this ?

If I remove filter from my aggregation it works fine.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.