# Deleting / editing existing analyzer in elastic index

**URL:** <https://discuss.elastic.co/t/deleting-editing-existing-analyzer-in-elastic-index/320838>\
**Category:** Elasticsearch\
**Created:** [December 8, 2022, 10:54pm UTC](https://discuss.elastic.co/t/deleting-editing-existing-analyzer-in-elastic-index/320838 "2022-12-08T22:54:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonid\_P](https://avatars.discourse-cdn.com/v4/letter/l/e99b99/32.png) [@Leonid\_P](https://discuss.elastic.co/u/Leonid_P)\
**Post date:** [December 8, 2022, 10:54pm UTC](https://discuss.elastic.co/t/deleting-editing-existing-analyzer-in-elastic-index/320838/1 "2022-12-08T22:54:41Z")

</div>

Hello!

Is it safe to delete or change an analyzer in an existing index?

Surfing through Stackoverflow and experimenting on my own I've found ways for both operations, i.e.

```auto
curl -X PUT "localhost:9200/index_name/_settings?pretty" -H 'Content-Type: application/json' -d'{
"analysis": {
"analyzer": {
"analyzer_name": {"filter":null,"tokenizer":null,"type":null}
}
}
}'

```

for deletion and just adding analyzer with the same name and different properties, say

```auto
curl -X PUT "localhost:9200/index_name/_settings?pretty" -H 'Content-Type: application/json' -d'{
"analysis": {
"analyzer": {
"analyzer_name": {"type":"custom","tokenizer":"whitespace"}
}
}
}'

```

for editing.

In both cases the index should be closed first, both commands respond with `"acknowledged" : true`. Command  
`curl -X GET "localhost:9200/index_name/_settings?pretty"`  
responds with what it is expected to respond (i.e. the analyzer has disappeared after the deletion command or the properties of the analyzer have changed after the editing command), and the index works OK after opening, at least it seems so after brief testing.

These feautures are very importaint and convinient, but are they actually safe, or they may corrupt documents or other parts of the index?

For compatibility reasons I'm using Elasticsearch 7.13.4 version.

Big thanks in advance!

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [December 9, 2022, 2:48am UTC](https://discuss.elastic.co/t/deleting-editing-existing-analyzer-in-elastic-index/320838/2 "2022-12-09T02:48:53Z")

</div>

Hi @Leonid_P

I usually create a new index when an analyzer is created and then use the Reindex API.  
This ensures that the new analyzer is applied to all documents.  
This is also good because you guarantee a backup index in case something goes wrong with the new index.

Doing it your way I think it's a very high risk if any failure occurs that's how you can lose your index.

---

<div class="post-metadata">

**Author:** ![Leonid\_P](https://avatars.discourse-cdn.com/v4/letter/l/e99b99/32.png) [@Leonid\_P](https://discuss.elastic.co/u/Leonid_P)\
**Post date:** [December 9, 2022, 6:20am UTC](https://discuss.elastic.co/t/deleting-editing-existing-analyzer-in-elastic-index/320838/3 "2022-12-09T06:20:50Z")

</div>

Thank you for reply!

The index I'm going to deal with is really HUGE. Reindexing it with following testing would take about a week. And on the other hand it is treated within the set of similar indexes which I wouldn't like to affect, that's why I don't want just to add a new analyzer with a new name either (all indexes in the set should have same names for analyzers).

The analyzer to be edited (or deleted and then added again with a new set of filters) is to be just a search analyzer, it will not be used in indexing documents, so this operation won't make different documents to be indexed in different ways.

So the question is, whether editing / deleting an existing analyzer is itself somehow more dangerous for internal index data than just adding a new analyzer as it is described at the end of [Update index settings API | Elasticsearch Guide [8.5] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html) page?

Probably if it is unsafe, acknowledging these editing / deletion analyzer commands should be treated as a bug?

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [December 9, 2022, 8:17am UTC](https://discuss.elastic.co/t/deleting-editing-existing-analyzer-in-elastic-index/320838/4 "2022-12-09T08:17:27Z")

</div>

What I exposed was my vision of treating the problem. Documentation can be followed for your purpose.  
I just work in a way to get more security.  
If you tested it and it worked in your test environment, the same should happen in production.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 6, 2023, 8:18am UTC](https://discuss.elastic.co/t/deleting-editing-existing-analyzer-in-elastic-index/320838/5 "2023-01-06T08:18:06Z")

</div>

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