# Possible to change property analyzer without dropping documents or full re-index?

**URL:** <https://discuss.elastic.co/t/possible-to-change-property-analyzer-without-dropping-documents-or-full-re-index/23786>\
**Category:** Elasticsearch\
**Created:** [June 16, 2015, 9:07pm UTC](https://discuss.elastic.co/t/possible-to-change-property-analyzer-without-dropping-documents-or-full-re-index/23786 "2015-06-16T21:07:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffevans](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jeffevans](https://discuss.elastic.co/u/jeffevans)\
**Post date:** [June 16, 2015, 9:07pm UTC](https://discuss.elastic.co/t/possible-to-change-property-analyzer-without-dropping-documents-or-full-re-index/23786/1 "2015-06-16T21:07:04Z")

</div>

We have a document type (call it "mytype") that exists on a large number of indeces. In a recent release, we added a new property to this type, but mistakenly we did not explicitly create the mapping prior to the release, and therefore the dynamic mapping was added with a non-specified analyzer. This is the output from \_mapping:

```
      "new-field" : {
        "type" : "string"
      }

```

This is _really_ what we want. "my\_custom\_analyzer" is already defined on the index, and is used for other properties:

```
      "new-field" : {
        "type" : "string",
        "analyzer":"my_custom_analyzer"
      }

```

Is there a way to accomplish this without removing or reindexing all the documents? If I only lose existing values within the previously defined "new-field" property, (keeping all other document data) then that's fine. I read through [this gist](https://gist.github.com/nicolashery/6317643) which makes it seem like it's possible, but I'm not able to get that to work. Perhaps that's just due to the fact that the gist was written for an older version (0.9, whereas we're currently on 1.4.4). I'm attempting that request via the following:

```
curl -X PUT 'http://my-es-server:9200/my_index/_mapping/mytype' -d ' {
 "properties": {
   "new-field": {
     "analyzer":"my_custom_analyzer"
     "type":"string"
   }
 }
 }'

```

This is the error:

> {"error":"IndexCreationException[[my\_index] failed to create index]; nested: ElasticsearchIllegalArgumentException[failed to find analyzer type [string] or tokenizer for [new-field]]; nested: NoClassSettingsException[Failed to load class setting [type] with value [string]]; nested: ClassNotFoundException[org.elasticsearch.index.analysis.string.StringAnalyzerProvider]; ","status":400}

Reading through [this blog post](https://www.elastic.co/blog/changing-mapping-with-zero-downtime) suggests I can do something like:

1. Define a new property ("new-field-2") with the analyzer I want
2. Rename the existing "new-field" to "new-field-unused" or something similar
3. Create an alias from "new-field" to "new-field-2"

Is that an approach that will work or is there a more straightforward way? Or am I completely off the mark? Thanks for any insight.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 17, 2015, 4:12am UTC](https://discuss.elastic.co/t/possible-to-change-property-analyzer-without-dropping-documents-or-full-re-index/23786/2 "2015-06-17T04:12:35Z")

</div>

You could specify the analyzer during query time, but that will get messy.

Best option is to fix the mapping and the reindex.

---

<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:** [July 6, 2017, 12:07am UTC](https://discuss.elastic.co/t/possible-to-change-property-analyzer-without-dropping-documents-or-full-re-index/23786/3 "2017-07-06T00:07:08Z")

</div>


