# Terms agg not giving all terms for huge text fields

**URL:** https://discuss.elastic.co/t/terms-agg-not-giving-all-terms-for-huge-text-fields/126132
**Category:** Elasticsearch
**Created:** [March 29, 2018, 5:15pm UTC](https://discuss.elastic.co/t/terms-agg-not-giving-all-terms-for-huge-text-fields/126132 "2018-03-29T17:15:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![krishna\_chaitanya](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krishna\_chaitanya](https://discuss.elastic.co/u/krishna_chaitanya)
#### Post date: [March 29, 2018, 5:15pm UTC](https://discuss.elastic.co/t/terms-agg-not-giving-all-terms-for-huge-text-fields/126132/1 "2018-03-29T17:15:30Z")

</div>

I have a text field which is big. (~3000 char). I am storing the flow/path of the user inside my application.

Doc1:  
`flow_path: "ABCD12345678,ABCD098765432,PQRS56789043,EFG321987309,ABCD12345678,ABCD098765432,PQRS56789043,EFG321987309,ABCD12345678,ABCD098765432,PQRS56789043,EFG321987309,ABCD12345678,ABCD098765432,PQRS56789043,EFG321987309,ABCD12345678,ABCD098765432,PQRS56789043,EFG321987309"`

Doc2:  
`flow_path: "ABCD12345678,ABCD098765432,PQRS56789043,EFG321987309"`

So, user steps are recorded inside this comma-separated string.

I want to be able to search and also aggregate on this field. So, by default, Elasticsearch created 1 analyzed and 1 non-analyzed string and I expected it to work for my usecase.

I am able to search using analyzed `flow_path` field as expected, but when aggregating on `flow_path.keyword` field, it is not producing all the terms as expected in Kibana.

Ex: (based on above example)  
`Term : Count`  
`ABCD12345678,ABCD098765432,PQRS56789043,EFG321987309 : 1`

Doc1 term is completely ignored. I increased the `size` parameter to huge value(20000), but still the issue persists.

Version: ES, Kibana 5.6.3

Please help how I can aggregate on such big text field getting all the terms.

---

<div class="post-metadata">

### Author: ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)
#### Post date: [March 30, 2018, 11:16am UTC](https://discuss.elastic.co/t/terms-agg-not-giving-all-terms-for-huge-text-fields/126132/2 "2018-03-30T11:16:00Z")

</div>

If you do not provide an explicit mapping for your index, string fields will be mapped like this:

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

```

If you go with this default mapping, the `.keyword` multifield (that you are aggregation on) has been mapped to ignore any values that have a length larger than 256 characters, [because of the `"ignore_above": 256` parameter](https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-above.html). The value in your Doc1 is longer than that, and that's why you're not getting that document back with the terms aggregation.

To fix this, you could change your mappings to allow longer values, for example setting `ignore_above` to 512.

Note that you can not update the mappings for existing indexes. You will have to reindex your data to a new index that has the updated mappings applied.

---

<div class="post-metadata">

### Author: ![krishna\_chaitanya](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krishna\_chaitanya](https://discuss.elastic.co/u/krishna_chaitanya)
#### Post date: [March 30, 2018, 1:56pm UTC](https://discuss.elastic.co/t/terms-agg-not-giving-all-terms-for-huge-text-fields/126132/3 "2018-03-30T13:56:04Z")

</div>

Thanks for the reply. Looks like that's the issue, I checked my mapping, and its 256 chars.

---

<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: [April 27, 2018, 1:56pm UTC](https://discuss.elastic.co/t/terms-agg-not-giving-all-terms-for-huge-text-fields/126132/4 "2018-04-27T13:56:07Z")

</div>

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