Skip to content
English
  • There are no suggestions because the search field is empty.

CLI: Query: Search for files based on the number of values in an array

name of the field you want to search in

Query Template


JSON
{ "query": { "bool": { "must": [ { "exists": { "field": "
      
       " } } ], "filter": { "script": { "script": { "source": "doc['
       
        .keyword'].values.size() 
         
         
          ", "lang": "painless" } } } } } } 
         
        
       
      


Example

Usecase: “I want to find all files in the index that have more than 2 rot_trivial values”

Query

JSON
{ "query": { "bool": { "must": [ { "exists": { "field": "rot_trivial" } } ], "filter": { "script": { "script": { "source": "doc['rot_trivial.keyword'].values.size() > 2", "lang": "painless" } } } } } }