elasticsearch script query with exists/missing filter -
i trying run script query filter. script should return me books title gt 30:
get books/_search { "filter" : { "script" : { "script" : "_source.title?.length() > 30" } } }
this works.
but if try add filter, want books not has 'type' field :
get book/_search { "filter" : { "script" : { "script" : "_source.title?.length() > 30" }, "missing" : { "field" : "type" }, } }
then error:
nested: elasticsearchparseexception[expected field name got start_object \"exists\"]; }]
so can query missing fields script filter?
you're on right track, need combine both of filters bool/must
query.
post book/_search { "filter": { "bool": { "must": [ { "script": { "script": "_source.title?.length() > 30" } }, { "missing": { "field": "type" } } ] } } }
Comments
Post a Comment