Hello,
I recently set up an elastic search cluster. I have created an index with some text field. I managed to add a new text field using the put_mapping API.
But I cannot update the related similarity. I get the following error message, regarding of the filed I try to work on:
RequestError(400, 'illegal_argument_exception', 'Mapper for [test] conflicts with existing mapping:\n[mapper [test] has different [similarity]]')
I use elasticsearch 7.4.1and elasticsearch-py 7.0.5 (but I get the same error if I do it with a curl -XPUT).
Here is my index structure after creation
and after adding a test field and defining a similarity that I want to use
I did the following code to insert the field and define the similarity:
request_test = {
"properties":
{"test": {'type': 'text'}
}
}
request_settings = {
"settings" : {
"index" : {
"similarity" : {
"my_similarity" : {
"type" : "DFI",
"independence_measure" : "saturated"
}
}
}
}
}
es.indices.close('test_index2')
es.indices.put_settings(request_settings,'test_index2')
es.indices.put_mapping(body=request_test,index='test_index2')
es.indices.open('test_index2')
So this works just fine. But when I try to force my_similarity for a field (any of them), I get the error, even though "similarity" is supposes to be a mapping parameter (https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-params.html)
Here is the code I use:
request_mapping = {
"properties": {'test': {'type': 'text', 'similarity': 'my_similarity'}}
}
es.indices.close('test_index2')
es.indices.put_mapping(body=request_mapping,index='test_index2')
es.indices.open('test_index2')
(and it is actually the same if I use BM25)
I get the following error:
RequestError(400, 'illegal_argument_exception', 'Mapper for [test] conflicts with existing mapping:\n[mapper [test] has different [similarity]]')
And I get the same error if I use the following command in a term:
curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/test_index2/_mapping -d '{"propertie...'
So there is obviously something that I don't understand, since it is said that is it possible to update the similarity, but I get an error saying it can't…
Many thanks for all the help you can provide.