Getting documents based on field length

I have uploaded nearly 1,000,000 JSON files into elastic search. I am looking for a query which will help me filter and return documents based on a condition of field length using kibana.
For example I have a field of phone numbers in my files, so I want to get only those files which consists of phone number length greater than 10, where (phone:) is the field. This must be done using kibana. Please assist me in it.

You should compute that value at index time. Like:

{
  "phone": "xyz",
  "phone_length": 3
}

You can do that at index time using a painless script processor.

If you really want to run that at search time, you can use a Script Query. But this will be slow to run IMO.

Can you give me a sample script query for retrieving the files with phone: whose length is greater than 10

No sorry. I don't use Painless myself.

Thankyou so much @dadoonet

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