I am using Elasticsearch 7.6.2 (by running the official docker image with the default options) and py-elasticsearch 7.6.0 (installed with version >=7.6 <8)
I am trying to create an index with a float
field like this (as described in the lib docs):
index_name = 'test_index'
body = {'mappings': {'properties': {'float_field': {'type': 'float'}}}}
client.create(index_name, body=body)
then I test if the type is working (I try to index an int to see if it converts to float as set in the mappings during index creation above):
id_ = 123
value = 11
client.index(index_name, body={'float_field': value}, id=id_)
r = client.get(index_name, id=id_)['_source']['float_field']
And the resulting value is integer, not float:
assert r == value # passes
assert isinstance(r, float) # AssertionError
so the mapping of float_field
to float
type doesn't seem to work, what am I doing wrong here?
the types seem to only be inferred automatically no matter what I set in mappings.