'Python elastic search gives error indexing document

I have a standard docker image image: docker.io/elasticsearch:8.2.0 which I am using the elasticsearch python client version 8.2.0.

When I run the command resp = es.index(index="es_index", id=i, document=doc) I receive the following error.

File "/usr/local/lib/python3.9/site-packages/elasticsearch/_sync/client/utils.py", line 414, in wrapped
return api(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/elasticsearch/_sync/client/__init__.py", line 2246, in index
return self.perform_request(  # type: ignore[return-value]
File "/usr/local/lib/python3.9/site-packages/elasticsearch/_sync/client/_base.py", line 321, in perform_request
raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(
elasticsearch.ApiError: ApiError(406, 'Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported', 'Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported')

doc is just a standard dictionary with a few keys and strings.

Any idea how I can get the document to index?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source