How to update ElasticSearch search_analyzer mapping without conflict on analyzer?

Also asked on StackOverflow

I'm using version 7.7 of ElasticSearch, LogStash and Kibana and trying to update an index mapping for a field is resulting in one of 2 errors:

  • mapper_parsing_exception: analyzer on field [title] must be set when search_analyzer is set
  • illegal_argument_exception: Mapper for [title] conflicts with existing mapping:\n[mapper [title] has different [analyzer]]

Here is the operation that I am attempting. If I remove "analyzer": "standard", I get the first error. If I leave it in, I get the second error.

PUT /my_index/_mapping
{
  "properties": {
    "title": {
      "type": "text",
      "analyzer": "standard",
      "search_analyzer": "synonyms"
    }
  }
}

However when I get the mapping with GET /my_index/_mapping, I don't see any analyzer defined:

"title" : {
  "type" : "text",
  "fields" : {
    "keyword" : {
      "type" : "keyword",
      "ignore_above" : 256
    }
  }
},

Extra Info

Here is how I setup the "synonyms" search analyzer, but I don't think that is relevant:

POST /my_index/_close
PUT /my_index/_settings
{
  "index": {
    "analysis": {
      "analyzer": {
        "synonyms": {
          "tokenizer": "whitespace",
          "filter": [
            "lowercase",
            "the_synonyms"
          ]
        }
      },
      "filter": {
        "the_synonyms": {
          "type": "synonym",
          "synonyms_path": "the_synonyms.txt",
          "updateable": true
        }
      }
    }
  }
}
POST /my_index/_open

The following works. Not sure there are any implications of doing it this way. I don't think so, but I could not find any documentation on it either, other than the documentation that states that the standard analyzer is the default analyzer. I essentially found this answer by guessing.

PUT /my_index/_mapping
{
  "properties": {
    "title": {
      "type": "text",
      "analyzer": "default",
      "search_analyzer": "synonyms"
    }
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.