添加新的建议上下文 - ElasticSearch Suggestions

Add new suggestion context - ElasticSearch Suggestions

我的索引映射中有这个搜索上下文

索引:地区

"place_suggest": {
  "type" : "completion",
  "analyzer" : "simple",
  "preserve_separators" : true,
  "preserve_position_increments" : true,
  "max_input_length" : 50,
  "contexts" : [
    {
      "name" : "place_type",
      "type" : "CATEGORY",
      "path" : "place_type"
    }
  ]
}

我想为这个映射添加一个新的上下文

{
  "name": "restricted",
  "type": "CATEGORY",
  "path": "restricted"
}

我试过使用更新映射 API 来添加这个新上下文,如下所示:

PUT region_test/_mapping/
{
  "properties" : {
    "place_suggest" : {
      "contexts": [
        "name": "restricted",
        "type": "CATEGORY",
        "path": "restricted"
      ]
    }
  }
}

我正在使用 Kibana 开发工具 运行 此查询。

您将无法通过添加新上下文来编辑您的字段。

您需要创建一个新映射和 re-index 您的索引。

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#change-existing-mapping-parms