4

I have the mapping

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

and I want to update the index parameter of the location field to true

I am trying

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

and I am getting

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

How to update the index parameter?

0

1 Answer 1

6

What you are trying to achieve is called breaking changes or conflicting changes and is not possible and same is mentioned in the error message.

Think of what index param does and why its breaking changes, from index docs

The index option controls whether field values are indexed. It accepts true or false and defaults to true. Fields that are not indexed are not queryable.

Earlier index value was false so your existing documents didn't have value indexed and wasn't queryable and now you changing to true which doesn't make sense as your earlier documents will not have the indexed value and that's the reason its called breaking changes.

You have to create a new index with new index value and you can use the reindex API for that.

Sign up to request clarification or add additional context in comments.

3 Comments

And use alias to avoid application side changes.
Here elastic.co/guide/en/elasticsearch/reference/current/… we can find that update is allowed to supported mapping parameters, and index parameter is listed
@Gibbs thanks for mentioning alias, wanted to add but forgot :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.