How can i fix this error Mapper for [description] conflicts with existing mapper:Cannot update parameter [analyzer] from [my_analyzer] to [default]

Viewed 1711

am new to elastic search.please help me out with this problem.

Am using elastic search version 7.13.2 .

I created an index with a custom analyzer and filter like this

PUT /analyzers_test
{
  "settings": {
    "analysis": {
      "analyzer": {
        "english_stop":{
          "type":"standard",
          "stopwords":"_english_"
        },
        "my_analyzer":{
          "type":"custom",
          "tokenizer":"standard",
          "char_filter":["html_strip"
            ],
            "filter":[
              "lowercase",
              "trim",
              "my_stemmer"]
        }
      },
      "filter": {
        "my_stemmer":{
          "type":"stemmer",
          "name":"english"
        }
      }
    }
  }
}

Then i created a mapping for the document i will have and specified my custom analyzer i created earlier (there is no document in the index yet) like so:

PUT /analyzers_test/_mapping
{
    "properties": {
      "description":{
        "type": "text",
        "analyzer": "my_analyzer"
      },
      "teaser":{
        "type": "text"
      
      }
    }
}

When i try try to create a document like so

POST /analyzers_test/1
{
  "description":"drinking",
  "teaser":"drinking"
}

i get the following error

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Mapper for [description] conflicts with existing mapper:\n\tCannot update parameter [analyzer] from [my_analyzer] to [default]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Mapper for [description] conflicts with existing mapper:\n\tCannot update parameter [analyzer] from [my_analyzer] to [default]"
  },
  "status" : 400
}

2 Answers

Use index API to add document to your index. You are missing the _doc

"You cannot change the mapping (including the analyzer) of an existing field. What you need to do if you want to change the mapping of existing documents is reindex those documents to another index with the updated mapping." Abdon Pijpelink

Click the name for the original discussion

Related