Elasticsearch throws a SearchParseException
while parsing query if there are some documents found not containing field used in sort criteria.
Apparently ElasticSearch won't sort on null values. I was assuming it would treat null as being at the start or end (as with SQL ordering) but I believe it also triggers this error.
So if you see this error, you may need to ensure the sort attribute has a default value when it's sent to ElasticSearch.
I had this error with Rails+ElasticSearch+Tire because the sort column didn't have a default value, so was being sent to ES as null.
This issue indicates null values are handling, but it wasn't my experience. It's something worth trying anyway.