【问题标题】:Update mapping index parameter of existing field in Elasticsearch更新 Elasticsearch 中现有字段的映射索引参数
【发布时间】:2020-11-24 16:32:02
【问题描述】:

我有映射

{
  "test" : {
    "mappings" : {
      "properties" : {
        "description" : {
          "type" : "text"
        },
        "location" : {
          "type" : "keyword",
          "index" : false
        },
        "title" : {
          "type" : "text"
        }
      }
    }
  }
}

我想将location字段的index参数更新为true

我在努力

PUT /test/_mapping
{
  
    "properties": {
        "location": { 
            "type": "keyword",
            "index": true
        }
    }
  
}

我得到了

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Mapper for [location] conflicts with existing mapping:\n[mapper [location] has different [index] values]"}],"type":"illegal_argument_exception","reason":"Mapper for [location] conflicts with existing mapping:\n[mapper [location] has different [index] values]"},"status":400}

如何更新index参数?

【问题讨论】:

    标签: elasticsearch elasticsearch-mapping


    【解决方案1】:

    您要实现的目标称为破坏性更改或冲突性更改,这是不可能的,错误消息中也提到了这一点。

    index docs 考虑索引参数的作用以及它的重大变化的原因

    索引选项控制字段值是否被索引。它接受 真或假,默认为真。未编入索引的字段是 不可查询。

    早期的索引值为false,因此您现有的文档没有索引值并且不可查询,现在您更改为true,这没有意义,因为您早期的文档将没有索引值并且这就是它被称为重大更改的原因。

    您必须创建一个具有新索引值的新索引,您可以为此使用reindex API

    【讨论】:

    猜你喜欢
    • 2019-04-16
    • 1970-01-01
    • 2017-03-11
    • 2017-03-14
    • 2021-08-27
    • 2017-07-28
    • 1970-01-01
    • 1970-01-01
    • 2017-10-08
    相关资源
    最近更新 更多