Adriano
Adriano

Reputation: 207

Change mapping property analyzer in Elasticsearch 5

I have an index on ES already created with a mapping.

I need to change a property analyzer to use a new analyzer. I was able to add the new analyzer to the index, but when trying to update the mapping property to use the new analyzer I got an exception.

My code:

var closeIndexResult = client.CloseIndex("index");     

 var result = client.Map<MyEntity>(m => m.Properties(prop =>
     prop.Text(t => t.Name(n => n.FirstName).Analyzer("myNewAnalizer"))
 ));

 Result here is not successful...

I am using ES 5 and Nest.

Is there a way to update my current property data to use the new analyzer without re-index all my data?

Upvotes: 1

Views: 453

Answers (1)

Nirmal
Nirmal

Reputation: 1336

No . Mapping decides how your data is indexed which means any changes to it will make current index inconsistent with mapping definition

Although you can add new types to an index, or add new fields to a type, you can’t add new analyzers or make changes to existing fields. If you were to do so, the data that has already been indexed would be incorrect and your searches would no longer work as expected.

When you need to make changes to existing fields, you should look at reindexing your data with the Reindex API

https://www.elastic.co/guide/en/elasticsearch/client/net-api/master/writing-analyzers.html

Upvotes: 2

Related Questions