-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Deprecation warnings in 7.15.0 pre-releases #1698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Updated this document with the body parameter's new schedule for removal in 9.0 instead of 8.0. |
For index {
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"dynamic": "strict",
"properties": {
"id": {
"ignore_above": 1024,
"type": "keyword"
},
"body": {
"type": "text",
"analyzer": "english"
}
}
}
} This allows me to have a single file per index and just load the config file straight into es.indices.create(index=index, body=load_json(config_fname)) With this change, I need to break that config file up and use a file per top-level attribute, or split the config = load_json(config_fname)
es.indices.create(index=index, settings=config["settings"], mappings=config["mappings"]) This seems like an unwanted side-effect for |
@joshdevins The case of "make a JSON body an API request" is likely to be applicable elsewhere too ( The goal of moving away from I know usage of client.indices.create(index="...", body={"settings": ..., "mappings": ...})
# in 8.0 will effectively be the same as:
client.indices.create(index="...", settings=..., mappings=...) The downside of above is a If you have a JSON body and the API encodes parameters into the body you can also do: client.indices.create(index="...", **raw_json) This is effectively what the rewriting of What are your thoughts on this? |
Hey @sethmlarson thanks for the detailed response! I think this makes sense and I'm glad we can document the discussion here as well. The splat [1] is probably the best advice for going forward in the case where I have a whole config file ready to go 👍 [1] client.indices.create(index="...", **raw_json) |
I am struggling to understand how to convert bool and agg queries to the new API format. Bool example:
Agg example:
Get indexes example:
|
https://elasticsearch-py.readthedocs.io/en/v8.0.0a1/api.html#elasticsearch.Elasticsearch.search |
@nkadochn These examples should work: es.search(
index=es_index_name,
query={"bool": {...}},
sort={"crawled_date": {"order": "desc"}}
) es.search(
index=es_index_name,
aggs={...},
size=0
) for index in es.indices.get(index="*"):
... |
I am not able to use new API on
|
@schettino72 Can you open a separate issue including your |
|
I think I am missing something from what I have read.
|
I wonder why |
@Hoodwinker13 your params still contain the
|
@kristall Here is the code that I have fixed. But I am still getting an error. |
@Hoodwinker13 Could you copy and paste the complete traceback as text into a GitHub comment? Can't see the full error in the picture. |
Just got up, and not yet thinking straight, so I deleted my comments, sry. |
is
|
index_name is a string. I have tried |
@sethmlarson This is the whole picture of the error that I receive. |
yes, using |
@Hoodwinker13 I'd build a simple working base and then add parameters until it breaks, so you know which... |
@sethmlarson I'd still be happy about an answer. And after an initial, "grrr more work", I actually like the changes a lot. |
@kristall From your screenshots it looks like you're using a document type ( mapping={
"properties": {
"error_10": {"type": "keyword"},
...
}
} |
Going to close and lock this issue as 8.0 is now released. Any issues should be opened separately. |
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.
Update: the
body
parameter for APIs is no longer deprecated as of elasticsearch-py 8.12For JSON requests each field within the top-level JSON object will become it's own parameter of the API with full type hinting
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:
Or use aliased names in body:
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:
However, you can't use both
document
andbody
.The
doc_type
parameter for non-Index APIsUsing
doc_type
for APIs that aren't related to indices or search is deprecated. Instead you should use thetype
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.The text was updated successfully, but these errors were encountered: