【问题标题】:ElasticsearchIllegalArgumentException[suggester [completion] requires context to be setup]ElasticsearchIllegalArgumentException [建议 [完成] 需要设置上下文]
【发布时间】:2016-10-29 12:05:02
【问题描述】:

我正在使用 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"
     ]
   }
  }
},

我需要Elastic Search的请求如下:

{ 
 "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

【问题讨论】:

  • 你用的是什么版本的ES?

标签: elasticsearch elasticsearch-rails


【解决方案1】:

查询中有语法错误。您必须指定上下文的名称

试试这个

{ 
 "suggest":{
  "suggestions":{
    "text":"M","
    completion":{
     "field":"person_name_suggest",
     "context":{"office_scope":890},
     "size":10
    }
   }
 }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-13
    • 2014-02-20
    • 1970-01-01
    相关资源
    最近更新 更多