我使用Elastic Search为名为people的索引实现自动提示字段:
字段person_name_suggest
-
person_name_suggest: {
type: "completion",
analyzer: "simple",
payloads: true,
preserve_separators: true,
preserve_position_increments: true,
max_input_length: 50,
context: {
office_scope: {
type: "category",
path: "office_scope",
default: [
"0"
]
}
}
},
我需要弹性搜索的请求如下:
{
"suggest":{
"suggestions":{
"text":"M","
completion":{
"field":"person_name_suggest",
"context":890,
"size":10
}
}
}
}
我收到以下错误 -
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[OsbgjmewT569a-7ZoNCMtg][people_2016_10_29][0]: SearchParseException[[people_2016_10_29][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"suggest":{"suggestions":{"text":"M","completion":{"field":"person_name_suggest","context":890,"size":10}}}}]]]; nested: ElasticsearchIllegalArgumentException[suggester [completion] requires context to be setup]; }
从我所看到的情况来看,我已将完成建议设置正确。
有人能指出我正确的方向吗?
正在使用的ElasticSearch版本为1.6
答案 0 :(得分:1)
查询中存在语法错误。您必须指定上下文的名称
试试这个
{
"suggest":{
"suggestions":{
"text":"M","
completion":{
"field":"person_name_suggest",
"context":{"office_scope":890},
"size":10
}
}
}
}