# String size limit in painless / keyword field?

**URL:** <https://discuss.elastic.co/t/string-size-limit-in-painless-keyword-field/108366>\
**Category:** Elasticsearch\
**Created:** [November 20, 2017, 10:56am UTC](https://discuss.elastic.co/t/string-size-limit-in-painless-keyword-field/108366 "2017-11-20T10:56:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fhdz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fhdz/32/64994_2.png) [@fhdz](https://discuss.elastic.co/u/fhdz)\
**Post date:** [November 20, 2017, 10:56am UTC](https://discuss.elastic.co/t/string-size-limit-in-painless-keyword-field/108366/1 "2017-11-20T10:56:39Z")

</div>

Hi there,

I am trying to perform some deduplication and sorting using "aggs" and "sort" queries. My documents contain some strings of different lengths and some of those strings are supposed to be part of the key for the aforementioned operations.  
Yet, it seems that the painless call to "doc['my\_field.keyword'].value" is cannot handle strings longer than 99 characters. Or is it the default parameters of the keyword field that limit it to 99 chars?

For example, the query below returns as first results strings of length 99, whereas I know for sure some of the 'my\_field' strings are longer.

```auto
{
  "query": {
    "match_all": {}
  },
  "sort": {
    "_script": {
      "type": "string",
      "order": "desc",
      "script": {
        "lang": "painless",
        "source": "doc['my_field.keyword'].values.toString().length()"
      }
    }
  }
}

```

And in the "aggs" query, I get some empty [] in the key:

```auto
GET /fr-es/tu/_search
{
    "size": 0,
    "aggs": {
      "duplicateCount": {"terms": {
        "script": {
          "lang": "painless",
          "source": "doc['my_field_1.keyword'].values + ':' + doc['my_field_2.keyword'].values"
          },
        "min_doc_count": 2
      },      
      "aggs": {
        "duplicateDocuments": {
          "top_hits": {}
        }
      }
    }
  }
}

```

gives results with the following: `"key": "[]:[]"` for long strings.

Thanks in advance,  
F

---

<div class="post-metadata">

**Author:** ![fhdz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fhdz/32/64994_2.png) [@fhdz](https://discuss.elastic.co/u/fhdz)\
**Post date:** [November 20, 2017, 2:13pm UTC](https://discuss.elastic.co/t/string-size-limit-in-painless-keyword-field/108366/2 "2017-11-20T14:13:19Z")

</div>

Nevermind, turns out the `ignore_above` parameter in the default mappings was set to `256` instead of the default `2147483647` that is mentioned [in the doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html)...

---

<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:** [December 18, 2017, 2:13pm UTC](https://discuss.elastic.co/t/string-size-limit-in-painless-keyword-field/108366/3 "2017-12-18T14:13:47Z")

</div>

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