Elasticsearch throws a SearchParseException
while parsing query if there are some documents found not containing field used in sort criteria.
Let me try to help in the case that the original answer doesn't work for you. For ES 6.x try the code below, ignore_unmapped is deprecated.
"sort" : [
{ "rating": {"order" : "desc" , "unmapped_type" : "long"} },
{ "price": {"order" : "asc" , "missing" : "_last" , "unmapped_type" : "long"} }
]
More about sorting you can find on:
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-sort.html