简体   繁体   中英

Update a property of the mapping on an existing index

Having this mapping:

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"},

        }}}}'

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"
}}}}'

But I get the error

{"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}

Any help? Thanks in advance.

PS: I'm using ES 2.3

You can't change the mappings in elastic. Afaik you have to reindex your data with the new mappings.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM