【发布时间】:2014-06-07 15:58:05
【问题描述】:
我在使用 elasticsearch 排序时遇到错误。
参考:
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
我正在使用带有 rails 的 elasticsearch-model。以下 sn-p 未排序并给我错误。
Ad.search(query: {
sort: [{posted_on: {order: "asc"}},
],
match: {
description: {
query: params[:search]
}
}
})
从终端尝试时出现以下错误。
curl -XPOST 'localhost:9200/_search' -d '{
"query": {
"match": {
"description": {
"query": "good center location"
}
},
"sort": [
"_score"
]
}
}'
回复是:
{
"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]}"
}
【问题讨论】:
标签: ruby-on-rails elasticsearch