【问题标题】:Update a property of the mapping on an existing index更新现有索引上的映射属性
【发布时间】:2017-10-25 23:46:11
【问题描述】:

有这个映射:

curl -XPUT 'http://myip:9200/test?pretty' -d'
{
    "mappings": {
        "items": {
           "dynamic": "strict",
           "properties" : {
                "title" : { "type": "string" },
                "body" : { "type": "string" },
                "publish_up" : { "type": "date",
                                 "format" : "yyyy-MM-dd HH:mm:ss",
                                 "copy_to": "publication_date"},
                "publication_date" : { "type": "date",
                                       "format" : "yyyy-MM-dd HH:mm:ss"},

        }}}}'

我想将属性publication_date 更改为"store" : "yes" 以返回值using fields。这是我的尝试:

curl -X PUT 'http://myip:9200/test/_mapping/items?ignore_conflicts=true' -d '{
  "items": {
    "properties": {
      "publication_date": {
        "type": "date",
        "format" : "yyyy-MM-dd HH:mm:ss",
        "store" : "yes"
}}}}'

但我得到了错误

{"error":{"root_cause":[{"type":"illegal_argument_exception","re​​ason":"Mapper for [publication_date] 与其他中的现有映射冲突 types:\n[mapper [publication_date] 有不同的 [store] values]"}],"type":"illegal_argument_exception","re​​ason":"映射器 [publication_date] 与其他中的现有映射冲突 types:\n[mapper [publication_date] 有不同的 [store] 值]"},"状态":400}

有什么帮助吗?提前致谢。

PS:我使用的是 ES 2.3

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    文档写入 ES(ES 2 以上版本)后,无法更新映射。

    由于更改映射意味着使已索引的文档无效,因此您需要使用正确的映射创建一个新索引,并将您的数据重新索引到该索引中。

    【讨论】:

      【解决方案2】:

      您无法更改弹性中的映射。 Afaik 您必须使用新的映射重新索引您的数据。

      【讨论】:

        猜你喜欢
        • 2019-04-16
        • 1970-01-01
        • 1970-01-01
        • 2017-03-11
        • 2020-11-24
        • 1970-01-01
        • 2017-10-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多