# Deleted mapping is still applied by Elasticsearch

**URL:** <https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820>\
**Category:** Elasticsearch\
**Created:** [October 10, 2018, 10:33am UTC](https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820 "2018-10-10T10:33:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_b](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@alex\_b](https://discuss.elastic.co/u/alex_b)\
**Post date:** [October 10, 2018, 10:33am UTC](https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820/1 "2018-10-10T10:33:04Z")

</div>

Hi,  
after changing a mapping, the old mapping is still applied. I restarted ES, then even restarted Windows, but the problem is still there.

An object type, lets call it ExampleType, is saved in an index, lets call it "example\_index".  
ExampleType has a property DoubleNumber of type double.

When creating a default ElasticClient, it changes field names to camel case:  
DoubleNumber -\> doubleNumber

At some point (ES 6.1 or 6.2) we switched to explicit mapping creation. In our custom mapping, property name was changed this way:  
DoubleNumber -\> double\_number

After deleting the index and creating it new the changes were applied as expected.

In the meantime, we switched to ES 6.4.0. Used Kibana is also 6.4.0.

Now I noticed, that field change can be disabled at all, if using  
`.DefaultFieldNameInferrer(name => name)`  
on ConnectionSetting of ElasticClient. Decided to make use of it.

Changed the custom mapping creation to not change field names. Expected field name mapping is:  
DoubleNumber -\> DoubleNumber

Deleted example\_index.  
In Kibana, 'GET example\_index/\_mapping' is throwing an exception.  
'GET \_mapping' is showing all mappings, but no mapping for example\_index.

Now I create the index:

```auto
elasticClient.CreateIndex("example_index", c => c.
InitializeUsing(new IndexState() { Settings = new IndexSettings() { NumberOfReplicas = 0, NumberOfShards = 1 } })

```

Then I set my custom mapping:  
`elasticClient.Map(putMappingRequest);`

In Kibana, I can see the new mapping now, the field name is 'DoubleNumber' as expected.

But when I index a new ExampleType with:  
`elasticClient.IndexDocument(myExample);`  
and then execute in Kibana:  
GET /\_search{"query": {"match" : { "\_index": "example\_index"} } }  
I get a result with 'double\_number' as property name in the document.

'GET example\_index/\_mapping'  
returnes a mapping, where the property is referenced twice:  
"DoubleNumber ": {"type": "double"},  
"double\_number": {"type": "double"}

I have no idea, where ES gets the old style property name mapping. It is not the default one. And it is not used anywhere.

An interesting fact is, that for a second index (lets call it "second\_index"), used in parallel with example\_index, the same error occurs, although second\_index does not ever used a custom mapping, but always a default mapping. Now second\_index also has a mapping with two definitions:  
"SomeNumber": {"type": "double"},  
"some\_number": {"type": "double"}  
and the second one used. Although this kind of name mapping was never ever applied to seond\_index.  
The only thing, that couples the two indices is that they are created/deleted using the same ElasticClient instance.

And for a third index, used in a different solution, where always a default mapping was used, the change of ConnectionSettings just worked and the index showed the expected behaviour after deleting and recreation.

A collegue using ES 6.2.0 is working on the same scenario. He has example\_index and second\_index. For example\_index a custom mapping with our renaming rule is applied (SomeProp -\> some\_prop), for second\_index is default mapping applied. He has not changed anything on that, but taking a look now, we see, that for second\_index, our custom renaming was applied on his machine.

How can I force ES to delete the renaming rule, that was applied in some previous mapping, but is no longer applied? Restarting has not worked.  
And how can I avoid the corruption of an index with renaming rules, that are defined for some other index only?

Alexander

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [October 10, 2018, 12:15pm UTC](https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820/2 "2018-10-10T12:15:55Z")

</div>

> [@alex\_b](#):
>
> How can I force ES to delete the renaming rule, that was applied in some previous mapping, but is no longer applied? Restarting has not worked.

The index mapping is saved with the index when the index was created so even if you delete the mapping and create a new one it will only affect future indices (but see [Updating existing field mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#_updating_existing_field_mappings)).

If you want all your old data to get the new mapping the only way I know of is to use the [Reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html) and create a new index with the old data. Because you create a new index it will get the new mapping and by indexing the documents from the old to the new index, they also get the new mapping. I've done this a few times myself and it's a pretty straight forward operation.

---

<div class="post-metadata">

**Author:** ![alex\_b](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@alex\_b](https://discuss.elastic.co/u/alex_b)\
**Post date:** [October 11, 2018, 7:09am UTC](https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820/3 "2018-10-11T07:09:04Z")

</div>

The affected index was deleted already. Somehow the renaming rule is saved somewhere and applied to several indices, not only to the one, it was defined for. And even if the index that the rule belonged to is deleted, the rule is still somewhere in ES and is applied.

Today I deleted all affected indices and ran the program with new index names, so new indices with new names were created. The ElasticClient has `.DefaultFieldNameInferrer(name => name)` on its setting. One index was created with a default mapping. The other index was created with a custom mapping. Both have the no longer existing property name renaming rule applied.

---

<div class="post-metadata">

**Author:** ![alex\_b](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@alex\_b](https://discuss.elastic.co/u/alex_b)\
**Post date:** [October 11, 2018, 8:17am UTC](https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820/4 "2018-10-11T08:17:43Z")

</div>

Deleted Elasticsearch. Installed version 6.4.2 (not upgraded, new installation). Created the indices. The old property name renaming is applied for both indices. Although the renaming is no longer defined anywhere in the program and although ES was reinstalled.

Help?

---

<div class="post-metadata">

**Author:** ![alex\_b](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@alex\_b](https://discuss.elastic.co/u/alex_b)\
**Post date:** [October 16, 2018, 7:29am UTC](https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820/5 "2018-10-16T07:29:01Z")

</div>

Still fighting with this problem. Deleted ES, deleted C:\ProgramData\Elastic, deleted Kibana.  
After this cleanup, no visible ES stuff was on the machine.  
Debugged my program to be very sure, that it does not provide some property renaming. The mapping stored to ES uses the unchanged property names. The object, that is indexed, has the unchanged property names.  
After reinstalling ES and creating the index, the expected mapping with unchanged property names is created by the program. In Kibana I can see, that the index is there and that it is correct.  
When continuing my program and indexing a file, the mapping is extended with changed property names (MyProperty -\> my\_property). And the added part of the mapping is used to index the document. This custom renaming is no longer present anywhere. But ES finds it somewhere...

Is there any data stored at other places then C:\Program Files\Elastic or C:\ProgramData\Elastic ?

---

<div class="post-metadata">

**Author:** ![alex\_b](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@alex\_b](https://discuss.elastic.co/u/alex_b)\
**Post date:** [October 16, 2018, 2:28pm UTC](https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820/6 "2018-10-16T14:28:46Z")

</div>

Got the error.  
The problem was not on ES side. In the connection settings, we pass a custom JsonSerializer and there we had the following:

```auto
protected override void ModifyContractResolver(ConnectionSettingsAwareContractResolver resolver) =>
    resolver.NamingStrategy = new SnakeCaseNamingStrategy();

```

The SnakeCaseNamingStrategy changes the properties (MyProperty -\> my\_property) when serializing the object to Json.  
Deleting this method from the custom serializer solves the problem.

---

<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:** [November 13, 2018, 2:40pm UTC](https://discuss.elastic.co/t/deleted-mapping-is-still-applied-by-elasticsearch/151820/7 "2018-11-13T14:40:32Z")

</div>

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