Change analyzer of specific property

HI guys,

I am new to elasticSearch and i am trying to do something.

after i insert data and index it, can i somehow change the analyzer of specific property?

for example this is the response of:
GET company-node/_mapping

{
"company-node": {
"mappings": {
"Organization": {
"properties": {
"country": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fullDescription": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}

i try to add english analyzer, but i get.
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Mapper for [description] conflicts with existing mapping in other types:\n[mapper [description] has different [analyzer]]"
}
],
"type": "illegal_argument_exception",
"reason": "Mapper for [description] conflicts with existing mapping in other types:\n[mapper [description] has different [analyzer]]"
},
"status": 400
}

this is what i try to do:
PUT company-node/_mapping/Organization
{
"properties": {
"description": {
"type": "text",
"analyzer": "english"
}
}
}

1 Like

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.

So, first create a new index, which you create with the new mapping. Then use the reindex API to get all documents from the old index A into the new index B. As those documents get reindexed, they will get the updated mapping applied to them. More info about the reindex API here: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

1 Like

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