elasticsearch - ElasticsearchIllegalArgumentException

标签 elasticsearch elasticsearch-1.6.0

我的代码是

curl -XGET 'http://localhost:9200/web/_suggest?pretty' -d '
{ "brand-suggest": {"completion": {"field": "nameSuggest","size":   "5","context": { "private": "false" }}, "text": "sampl"}}'

尝试Elasticsearch建议查询时出现错误。
"index" : "webpage",
      "shard" : 4,
      "status" : 500,
      "reason" : "BroadcastShardOperationFailedException[[tellofy][4] ];  nested: ElasticsearchException[failed to execute suggest]; nested: ElasticsearchIllegalArgumentException[suggester [completion] doesn't expect any context]; "
    }

出现上述错误的原因是什么。我找不到该错误的原因。

最佳答案

nameSuggest具有completion类型,但没有context,因此不允许您的建议查询指定context
看看normal completion fields completion fields with context之间的区别

如果您想运行以下查询

curl -XGET 'http://localhost:9200/web/_suggest?pretty' -d '{
  "brand-suggest": {
    "completion": {
      "field": "nameSuggest",
      "size": "5",
      "context": {
        "private": "false"
      }
    },
    "text": "sampl"
  }
}'

您需要将nameSuggest字段的映射更改为此,即添加上下文配置部分:
{
  "type": "completion",
  "analyzer": "simple",
  "search_analyzer": "simple",
  "context": {
    "private": {
      "type": "category",
      "path": "private"
    }
  }
}

关于elasticsearch - ElasticsearchIllegalArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39011617/

相关文章:

java - spring boot 2 与 elasticsearch 2.4 通过 spring data

elasticsearch - 基于某些字段的ElasticSearch结果排序(相关分数)(增强)

java - 如何使用嵌入式 ElasticSearch 进行集成测试

scala - elasticsearch 1.6 elasticsearch命令和代码在jdk11中不起作用

docker - elasticsearch-1.6 连接到其 docker 容器时无法初始化类 org.elasticsearch.monitor.jvm.JvmInfo

java - 创建一个简单的工作spring boot

elasticsearch - 如何使用官方的nodejs库为Elasticsearch设置ttl?

php - 将中缀表达式转换为 Elasticsearch 查询