更新现有索引上映射的属性 [英] Update a property of the mapping on an existing index

查看:439
本文介绍了更新现有索引上映射的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有以下映射:

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为了返回值使用字段。这是我的尝试:

I want to change the property publication_date to "store" : "yes" in order to return the values using fields. This is my try:

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,reason:mapper
for [publication_date]与其他
类型中的现有映射冲突:\\\
[mapper [publication_date]具有不同的[store ]
值]}],type:illegal_argument_exception,reason:
[publication_date]的映射与其他
类型中的现有映射冲突:\\\
[mapper [publication_date]有不同的[store]
值]},status:400}

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Mapper for [publication_date] conflicts with existing mapping in other types:\n[mapper [publication_date] has different [store] values]"}],"type":"illegal_argument_exception","reason":"Mapper for [publication_date] conflicts with existing mapping in other types:\n[mapper [publication_date] has different [store] values]"},"status":400}

任何帮助?感谢提前。

PS:我正在使用ES 2.3

PS: I'm using ES 2.3

推荐答案

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

It is not possible to update the mapping once document is written into ES (above ES 2 version).

由于更改映射意味着已经编制索引的文档无效,将需要创建一个具有正确映射的新索引,并将您的数据重新索引到索引中。

Since changing the mapping would mean invalidating already indexed documents, you would need to create a new index with the correct mappings and re-index your data into that index.

这篇关于更新现有索引上映射的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆