How to get a field value greater than 50 characters

(Anna) #1

ES version 6.1.1

"fieldName": {
"type": "keyword"

(Abdon Pijpelink) #2

Do you want to query your data for documents that contain a field with more than 50 characters? You can use a script for that.

For example, a script query (, that calculates the length of the field and returns true if the field has more than 50 characters.

One warning: script queries work well for queries that you do not use too often. Script queries are generally expensive, so you want to use them as little as possible.

If you want to query on the length of the field a lot, it's better to pre-process your documents when you index them, and calculate the length of the field then. You could use the ingest node functionality for that ( with a script processor ( that calculates the length of fieldName and adds the result as a value of a new field in your documents. You can then use a simple range query on that calculated field.

(system) #3

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