Add mapping response mapper_exception in ElasticSearch

Hi,
I need synonyms for searching my documents and mainly fellow some monuals published, eg.

POST /my_index/_close
PUT /my_index/_settings
{
  "settings": {
    "analysis": {
      "filter": {
        "my_synonym_filter": {
          "type": "synonym",
          "synonyms_path": "synonyms.txt",
		  "updateable": true
        }
      },
      "analyzer": {
        "my_synonym_analyzer": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "my_synonym_filter"
          ]
        }
      }
    }
  }
}

Now I like to assign my_synonym_analyzer to the field content using this request:

PUT /my_index/_mapping
{
  "properties": {
    "content": {
      "type": "text",
      "analyzer": "my_synonym_analyzer"
    }
  }
}

But the result reports an error:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_exception",
        "reason": "analyzer [my_synonym_analyzer] contains filters [my_synonym_filter] that are not allowed to run in index time mode."
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping: analyzer [my_synonym_analyzer] contains filters [my_synonym_filter] that are not allowed to run in index time mode.",
    "caused_by": {
      "type": "mapper_exception",
      "reason": "analyzer [my_synonym_analyzer] contains filters [my_synonym_filter] that are not allowed to run in index time mode."
    }
  },
  "status": 400
}

I study a couple of tutorials but it seems that's a common way to assign the mapping.
Version is 8.15.1 and field type of content is text what I already checked.
Any idea what I'm doing wrong?

Thanks,
Andre

Hi @AndreAT,

Welcome! I believe your issue is down to the updateable option. There is a similar issue with a corresponding fix here to use separate search and index analysers.

Hope that helps!

Hi Carly,
thank you.
I tried this also but with the same result.
What I tried was to overwrite - maybe I have to delete settings before (how to do?)?
With updateable : false it also doesn't work.

Thank you,
Andre

Ok, can you perhaps share what you're trying to do? What do you mean by:

With updateable : false it also doesn't work.

As in you receive the same error? Did you delete the index before recreating it?

Yes, I tried to change updateable and run it like this:

But than I get the previous error again after executing.

PUT /my_index/_mapping
{
  "properties": {
    "content": {
      "type": "text",
      "analyzer": "my_synonym_analyzer"
    }
  }
}

I tried to deleted the index and now another error occurs so I expect the issue is fine, thank you.

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": """Mapper for [content] conflicts with existing mapper:
	Cannot update parameter [analyzer] from [default] to [my_synonym_analyzer]"""
      }
    ],
    "type": "illegal_argument_exception",
    "reason": """Mapper for [content] conflicts with existing mapper:
	Cannot update parameter [analyzer] from [default] to [my_synonym_analyzer]"""
  },
  "status": 400
}

I get now - I think I have to delete existing mapper first.

Yes, try deleting the existing mapper and recreating. Let us know how you get on.