String size limit in painless / keyword field?

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.

{
  "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:

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

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...

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