# Keyword default size

**URL:** <https://discuss.elastic.co/t/keyword-default-size/238735>\
**Category:** Elasticsearch\
**Created:** [June 25, 2020, 5:52pm UTC](https://discuss.elastic.co/t/keyword-default-size/238735 "2020-06-25T17:52:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjabrantes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjabrantes/32/78091_2.png) [@cjabrantes](https://discuss.elastic.co/u/cjabrantes)\
**Post date:** [June 25, 2020, 5:52pm UTC](https://discuss.elastic.co/t/keyword-default-size/238735/1 "2020-06-25T17:52:17Z")

</div>

Hi,

As far as i know the keywords are created automatically with 256.  
Problem is that when i do some group by term with that field some are missing because they are a bit above 256.

I can add the mapping with 300, but how to change the default?

I have in logstash:  
index =\> "mylogs-%{+YYYY.MM.dd}"

So every day a new index will be create, how to create that index already with 300?

Thanks,

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [June 25, 2020, 8:32pm UTC](https://discuss.elastic.co/t/keyword-default-size/238735/2 "2020-06-25T20:32:45Z")

</div>

@cjabrantes

> As far as i know the keywords are created automatically with 256.

If the type of the field is keyword, you can specify ignore\_above to not index values larger than N characters. If not specified N defaults to ~2Billion characters. But the keyword sub field of an analyzed field uses ignore\_above 256 as default.

If the field is analyzed tokenizer can restrict tokens to max length. The StandardAnalyzer has max\_token\_length property that defaults to 255.

> Problem is that when i do some group by term with that field some are missing because they are a bit above 256.

Can you post your index mapping and a query you are running?

---

<div class="post-metadata">

**Author:** ![cjabrantes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjabrantes/32/78091_2.png) [@cjabrantes](https://discuss.elastic.co/u/cjabrantes)\
**Post date:** [June 25, 2020, 11:11pm UTC](https://discuss.elastic.co/t/keyword-default-size/238735/3 "2020-06-25T23:11:02Z")

</div>

Hi,

This is the mapping created for the field when logstash sends the date to elastic, i just send log.  
"log" : {  
"type" : "text",  
"fields" : {  
"keyword" : {  
"type" : "keyword",  
"ignore\_above" : 256  
}  
}  
},

this is working as expected according to:

> **[Elasticsearch replaces string type with two new types text and keyword.](https://www.elastic.co/blog/strings-are-dead-long-live-strings)**
>
> On using text types for full text search and keyword type for keyword search in Elasticsearch 5.0.

  
By default a string now is mapped to text and keyword, so the question is how to change the default size of the keyword, is that an option in elastic? or do i have to "explicitly say it" in logstash?

If in logstash what is the correct why of doing it? In mudate convert i dont see any keyword.

Thanks,

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [June 26, 2020, 3:11am UTC](https://discuss.elastic.co/t/keyword-default-size/238735/4 "2020-06-26T03:11:34Z")

</div>

One way you can achieve this is by defining template for these indices. This example shows a single named field. You can use dynamic mapping for multiple (or all text) fields.

```auto
{
  "template": "mylogs-*",
  "mappings": {
    "properties": {
      "log": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 300
          }
        }
      }
    }
  },
  "aliases": {}
}

```

---

<div class="post-metadata">

**Author:** ![cjabrantes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjabrantes/32/78091_2.png) [@cjabrantes](https://discuss.elastic.co/u/cjabrantes)\
**Post date:** [June 26, 2020, 12:54pm UTC](https://discuss.elastic.co/t/keyword-default-size/238735/5 "2020-06-26T12:54:39Z")

</div>

Nice, works as i pretend!

Thanks!

---

<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:** [July 24, 2020, 12:54pm UTC](https://discuss.elastic.co/t/keyword-default-size/238735/6 "2020-07-24T12:54:45Z")

</div>

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