ElasticSearch sorting by text length and huge ignore_above

I need to sort my elasticsearch documents by length of a text field. However, this field can sometimes contain a very large amount of text (up to 15000 characters). I am aware that the ignore_above parameter, which defaults to 256, can be used to limit the length of the text that is indexed.

Is it okay to change the ignore_above parameter to 15,000 to enable sorting by text length?

Alternatively, would it be a better solution to create an additional field, such as textLength, which contains the length of the text (e.g., textLength: 14000), and then sort by this textLength field?

Thanks

I think the limit you mentioned is for keyword fields, not text fields.

This would be a very inefficient way of sorting by length. Much better to store the length of the text as another field.

1 Like