# Aggregation count are not matching with bucket results

**URL:** <https://discuss.elastic.co/t/aggregation-count-are-not-matching-with-bucket-results/144426>\
**Category:** Elasticsearch\
**Created:** [August 14, 2018, 11:31pm UTC](https://discuss.elastic.co/t/aggregation-count-are-not-matching-with-bucket-results/144426 "2018-08-14T23:31:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snigdharao](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@snigdharao](https://discuss.elastic.co/u/snigdharao)\
**Post date:** [August 14, 2018, 11:31pm UTC](https://discuss.elastic.co/t/aggregation-count-are-not-matching-with-bucket-results/144426/1 "2018-08-14T23:31:52Z")

</div>

I have a scenario where a field is of array data type and i need to perform autocomplete.  
I have to filter my aggregation results.I am not able to do it for some reason , Attaching my query and results.Please let me know if i can perform this in elastic  
Query  
```  
GET contracts/doc/\_search  
{

````
      "size":0,
     
     "query":{
       "bool":{
         "must":{
           "match_phrase":{
             "commodity_line.autocomplete":"3"
             
           }
         }
         
       }
     },

      "aggs" : {
                "vendor_names": {
                 
                 
              "filter":{
                "term":{
                "commodity_line":"3"
                }
              },
              "aggs":{
                "names":{
                  "terms":{
                    "field":"commodity_line.keyword",
                    "size":1000
                  }
                }
              }
                   
                  }
                }
              
          
       }
```

````

Results for aggregation:

 ![17%20PM](https://us1.discourse-cdn.com/elastic/original/3X/9/2/92f52d279f511f114e631fbc7b3ee18024ed6050.png)  
aggregations doc\_count shows 188 but the buckets have results for all arrays matching 3. How can i filter and just have the ones matching

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 11, 2018, 11:31pm UTC](https://discuss.elastic.co/t/aggregation-count-are-not-matching-with-bucket-results/144426/2 "2018-09-11T23:31:54Z")

</div>

Closed on September 11, 2018, 11:31pm UTC

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