Description
If you're seeing this you likely received a deprecation warning from a 7.15.0 pre-release. Thanks for trying out in-development software
The v8.0.0 roadmap includes a list of breaking changes that will be implemented to make the Python Elasticsearch client easier to use and more discoverable. To make the upgrade from the 7.x client to the 8.0.0 client as smooth as possible for developers we're deprecating options and usages that will be removed in either 8.0 or 9.0.
This also means that you'll get an early preview for the great things to come in the 8.0.0 client starting in 7.x, which we're pretty excited about!
Which APIs are effected?
All APIs will emit deprecation warnings for positional argument use in 7.15.0.
The following APIs will start emitting deprecation warnings regarding the body
parameters. This list may change leading up to the 7.15.0 release.
search
index
create
update
scroll
clear_scroll
search_mvt
indices.create
The following APIs will start emitting deprecation warnings regarding doc_type
parameters.
nodes.hot_threads
license.post_start_trial
What is being deprecated?
Starting in 7.15.0 the following features will be deprecated and are scheduled for removal in 9.0.0:
Positional arguments for APIs are deprecated
Using keyword arguments has always been recommended when using the client but now starting in 7.15.0 using any positional arguments will emit a deprecation warning.
# ✅ Supported usage:
es.search(index="index", ...)
# ❌ Deprecated usage:
es.search("index", ...)
Update: the body
parameter for APIs is no longer deprecated as of elasticsearch-py 8.12
For JSON requests each field within the top-level JSON object will become it's own parameter of the API with full type hinting
# ✅ New usage:
es.search(query={...})
# ✅ Accepted usage:
es.search(body={"query": {...}})
body
can also be bytes as long as they're valid JSON, which can be useful as an optimization to avoid serialization by elasticsearch-py.
You should not mix parameters with body:
# ❌ Deprecated usage:
es.search(body={"query": {...}}, from_=10)
# ✅ Correct usages:
es.search(query={...}, from_=10)
es.search(body={"query": {...}, "from": 10})
Or use aliased names in body:
# ❌ Deprecated usage:
es.search(body={"query": {...}, "from_": 10})
# ✅ Correct usage:
es.search(body={"query": {...}, "from": 10})
For non-JSON requests or requests where the JSON body is itself an addressable object (like a document) each API will have the parameter renamed to a more semantic name:
# ✅ New usage:
es.index(document={...})
# ✅ Accepted usage:
es.index(body={...})
However, you can't use both document
and body
.
The doc_type
parameter for non-Index APIs
Using doc_type
for APIs that aren't related to indices or search is deprecated. Instead you should use the type
parameter.
See #1713 for more context for this change.
For APIs that are related to indices or search the doc_type
parameter isn't deprecated client-side, however mapping types are deprecated in Elasticsearch and will be removed in 8.0.
# ✅ New usage:
es.nodes.hot_threads(type="cpu")
# ❌ Deprecated usage:
es.nodes.hot_threads(doc_type="cpu")