Avión
Avión

Reputation: 8376

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

Upvotes: 1

Views: 1026

Answers (2)

Julina
Julina

Reputation: 757

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.

Upvotes: 2

Freddy
Freddy

Reputation: 156

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

Upvotes: 2

Related Questions