I want to make a query that counts how many elements there are in the field that is a array of jsons objects.
When I run:
{script: { script: "doc['field_name'].values.length() > 0"}}
I get:
"No field found for [field_name] in mapping with types "
I have set mapping for field_name as nested, but still I am getting the same error
I have tried multiple variations for the query but none of them worked:
"script" : "params['_source']['field_name'].length() > 1"
"script" : "params['_source']['field_name'].size() > 1"
"script" : "params['_source']['field_name'].values.size() > 1"
"script" : "params['_source']['field_name.keyword'].values.size() > 1"
"script" : {"source": "doc['ctx._source.field_name'].lenght() > 0" }}
and other variations.
What am I doing wrong ?