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:
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