Elasticsearch throws a SearchParseException
while parsing query if there are some documents found not containing field used in sort criteria.
SearchParseException: Parse Failure [No mapping found for [price] in order to sort on]
How can I successfully search these documents, even if some are missing the price
field?
After digging more, I found the solution as given below. ignore_unmapped
should be explicitly set to true
in the sort clause.
"sort" : [
{ "rating": {"order" : "desc" , "ignore_unmapped" : true} },
{ "price": {"order" : "asc" , "missing" : "_last" , "ignore_unmapped" : true} }
]
For further information have a look at the Elasticsearch references for: