I am getting error with elasticsearch sort.
references:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html
I am using elasticsearch-model with rails. The following snippet was not sorting and giving me error.
Ad.search(query: {
sort: [{posted_on: {order: "asc"}},
],
match: {
description: {
query: params[:search]
}
}
})
The following is error when trying from terminal.
curl -XPOST 'localhost:9200/_search' -d '{
"query": {
"match": {
"description": {
"query": "good center location"
}
},
"sort": [
"_score"
]
}
}'
response is:
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[eF0LAz1gQxOXKPlYGjj9eA][.marvel-2014.06.07][0]: SearchParseException[[.marvel-2014.06.07][0]: query[block.2.description:good block.2.description:center block.2.description:location],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n \"query\" : {\n \"match\" : {\n \"description\" : {\n \"query\" : \"good center location\"\n }\n },\n \"sort\" : [\"_score\"]\n }]]]; nested: ElasticsearchParseException[Expected field name but got START_ARRAY \"sort\"]; }{[eF0LAz1gQxOXKPlYGjj9eA][.marvel-2014.05.29][0]: SearchParseException[[.marvel-2014.05.29][0]: query[block.2.description:good block.2.description:center block.2.description:location],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n \"query\" : {\n \"match\" : {\n \"description\" : {\n \"query\" : \"good center location\"\n }\n },\n \"sort\" : [\"_score\"]\n }]]]; nested: ElasticsearchParseException[Expected field name but got START_ARRAY \"sort\"]; }{[eF0LAz1gQxOXKPlYGjj9eA][.marvel-2014.05.31][0]: SearchParseException[[.marvel-2014.05.31][0]: query[block.2.description:good block.2.description:center block.2.description:location],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n \"query\" : {\n \"match\" : {\n \"description\" : {\n \"query\" : \"good center location\"\n }\n },\n \"sort\" : [\"_score\"]\n }]]]; nested: ElasticsearchParseException[Expected field name but got START_ARRAY \"sort\"]; }{[eF0LAz1gQxOXKPlYGjj9]}"
}

