# Different results between filter and terms within unique count

**URL:** <https://discuss.elastic.co/t/different-results-between-filter-and-terms-within-unique-count/153703>\
**Category:** Elasticsearch\
**Created:** [October 24, 2018, 3:40am UTC](https://discuss.elastic.co/t/different-results-between-filter-and-terms-within-unique-count/153703 "2018-10-24T03:40:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![haries\_fajar\_nugroho](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@haries\_fajar\_nugroho](https://discuss.elastic.co/u/haries_fajar_nugroho)\
**Post date:** [October 24, 2018, 3:40am UTC](https://discuss.elastic.co/t/different-results-between-filter-and-terms-within-unique-count/153703/1 "2018-10-24T03:40:01Z")

</div>

Hello,

I have questions about results differences between filter and terms (i'm using unique count).

By using filter, i get 531 value, the same result compared with the docs that presented (531). But if i use terms, i get 544 value, bigger result compared with the docs that presented (531). If i count the docs, it is 531 documents.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/b/5b2a3e44a06ebbb5551bbf6a05357323a3d9cb5c.png)

The nearest explanation is in this article: [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order)

But that article is explaining about, smaller count if we use terms. What happened to me, i get bigger count by using terms.

Could someone help me regarding this ?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 24, 2018, 12:17pm UTC](https://discuss.elastic.co/t/different-results-between-filter-and-terms-within-unique-count/153703/2 "2018-10-24T12:17:42Z")

</div>

is it possible that some documents contain an array of data on the field you are aggregating on like `field: ['foo', 'bar']`, so that they fall into two buckets?

Also, can you clarify what you refer to as `unique count` in this context? Maybe I am misreading this.

--Alex

---

<div class="post-metadata">

**Author:** ![haries\_fajar\_nugroho](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@haries\_fajar\_nugroho](https://discuss.elastic.co/u/haries_fajar_nugroho)\
**Post date:** [October 24, 2018, 1:54pm UTC](https://discuss.elastic.co/t/different-results-between-filter-and-terms-within-unique-count/153703/3 "2018-10-24T13:54:59Z")

</div>

Hi,

It doesn't have any array. The unique count is for a port number of a switch, example: BIN-SW-01 Fa0/1. So, "BIN" refer to location of the switch.

---

<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:** [November 21, 2018, 1:55pm UTC](https://discuss.elastic.co/t/different-results-between-filter-and-terms-within-unique-count/153703/4 "2018-11-21T13:55:03Z")

</div>

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