# Term Aggregation: Count Duplicates

**URL:** <https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569>\
**Category:** Kibana\
**Created:** [December 5, 2018, 4:11pm UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569 "2018-12-05T16:11:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cebor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cebor/32/38476_2.png) [@cebor](https://discuss.elastic.co/u/cebor)\
**Post date:** [December 5, 2018, 4:11pm UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569/1 "2018-12-05T16:11:07Z")

</div>

Hello,

my TA pushes following doc to my elasticsearch:

> <https://gist.github.com/cebor/0b158d3743ec7de00f3da751c46a5ef4>

I want to visualize the count of all doc.test\_cases[''].verdict terms.

The visualisation omits duplicate verdicts. Got the following result:  
passed: 1 skipped: 1 failed: 1

My expected result is:  
passed: **2** skipped: 1 failed: 1

What can i do here, is my doc pushed to elasticsearch incorrect?

KR  
cebor

---

<div class="post-metadata">

**Author:** ![Aaron\_Caldwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_caldwell/32/45755_2.png) [@Aaron\_Caldwell](https://discuss.elastic.co/u/Aaron_Caldwell)\
**Post date:** [December 5, 2018, 6:00pm UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569/2 "2018-12-05T18:00:41Z")

</div>

Hello Cebor,

Could you post a screenshot of the visualization you've produced along with your field selections on the side?

Thanks,  
Aaron

---

<div class="post-metadata">

**Author:** ![cebor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cebor/32/38476_2.png) [@cebor](https://discuss.elastic.co/u/cebor)\
**Post date:** [December 5, 2018, 7:05pm UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569/3 "2018-12-05T19:05:01Z")

</div>

![10](https://us1.discourse-cdn.com/elastic/original/3X/c/7/c758847a47adb80fd23ec30d334be411556443a2.jpeg)

Here it is.

---

<div class="post-metadata">

**Author:** ![cebor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cebor/32/38476_2.png) [@cebor](https://discuss.elastic.co/u/cebor)\
**Post date:** [December 5, 2018, 7:53pm UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569/4 "2018-12-05T19:53:43Z")

</div>

Is it possible, that the problem is in the mapping? "verdict" is defined as follows:

```
"verdict": {
   "type": "text",
    "fields": {
     "keyword": {
        "type": "keyword",
        "ignore_above": 256
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![Aaron\_Caldwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_caldwell/32/45755_2.png) [@Aaron\_Caldwell](https://discuss.elastic.co/u/Aaron_Caldwell)\
**Post date:** [December 6, 2018, 12:53am UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569/5 "2018-12-06T00:53:50Z")

</div>

Nothing's jumping out at me. I thought maybe you were doing a unique count on the terms agg but that's not the case. Just to be sure, can you run `GET <your index name>/_search` from the dev tools and make sure both documents are in the results?

---

<div class="post-metadata">

**Author:** ![le\_walt](https://avatars.discourse-cdn.com/v4/letter/l/ba9def/32.png) [@le\_walt](https://discuss.elastic.co/u/le_walt)\
**Post date:** [December 6, 2018, 8:37am UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569/6 "2018-12-06T08:37:03Z")

</div>

Is there a Sum of Qty rather than count of items under the metrics Field?

---

<div class="post-metadata">

**Author:** ![cebor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cebor/32/38476_2.png) [@cebor](https://discuss.elastic.co/u/cebor)\
**Post date:** [December 6, 2018, 9:36am UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569/7 "2018-12-06T09:36:57Z")

</div>

"GET \<your index name\>/\_search" shows me all the data correctly, i think the problem is with the array, should be declared as nested.

See: [https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html)

But nested datatypes are not visualizable, so my solution for now is to push each testcase as single entry to my index.

---

<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:** [January 3, 2019, 9:37am UTC](https://discuss.elastic.co/t/term-aggregation-count-duplicates/159569/8 "2019-01-03T09:37:08Z")

</div>

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