Describe the feature:
Elasticsearch version 7.15
elasticsearch-py
version (elasticsearch.__versionstr__
): 7.15.2
Please make sure the major version matches the Elasticsearch server you are running.
Description of the problem including expected versus actual behavior:
I am getting this deprecated message when running a python script in 7.15.2. It says...
/mnt/isilon/SCRIPTS/bin/ICD10Import.py:347: DeprecationWarning: The 'body' parameter is deprecated for the 'index' API and will be removed in a future version. Instead use the 'document' parameter. See Deprecation warnings in 7.15.0 pre-releases · Issue #1698 · elastic/elasticsearch-py · GitHub for more information
I have read the suggested URL, and it says to replace body with document in the code as in...
if not es.indices.exists(index="adn"):
response = es.indices.create(
index="adn",
# body=icd10adn,
document=icd10adn,
#mappings=icd10adn,
ignore=400 # ignore 400 already exists code
)
When I do this, I get an error...
/mnt/isilon/opt/python/bin/python3 ICD10Import.py --feed TEST --log DEBUG
/mnt/isilon/SCRIPTS/bin/ICD10Import.py:310: DeprecationWarning: The 'body' parameter is deprecated for the 'create' API and will be removed in a future version. Instead use API parameters directly. See Deprecation warnings in 7.15.0 pre-releases · Issue #1698 · elastic/elasticsearch-py · GitHub for more information
response = es.indices.create(
Traceback (most recent call last):
File "/mnt/isilon/SCRIPTS/bin/ICD10Import.py", line 573, in
main()
File "/mnt/isilon/SCRIPTS/bin/ICD10Import.py", line 317, in main
response = es.indices.create(
File "/mnt/isilon/opt/python/lib/python3.10/site-packages/Elasticsearch/client/utils.py", line 301, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
TypeError: IndicesClient.create() got an unexpected keyword argument 'document'
[ingmar@ip-172-31-30-59 bin]$ /mnt/isilon/opt/python/bin/python3 ICD10Import.py --feed TEST --log DEBUG
Traceback (most recent call last):
File "/mnt/isilon/SCRIPTS/bin/ICD10Import.py", line 574, in
main()
File "/mnt/isilon/SCRIPTS/bin/ICD10Import.py", line 310, in main
response = es.indices.create(
File "/mnt/isilon/opt/python/lib/python3.10/site-packages/Elasticsearch/client/utils.py", line 301, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
TypeError: IndicesClient.create() got an unexpected keyword argument 'document'
So the suggestion as stated in Deprecation warnings in 7.15.0 pre-releases · Issue #1698 · elastic/elasticsearch-py · GitHub doesn't seem to work?
I saw another suggestion in https://discuss.elastic.co/ which said using mappings rather than body will get rid of the deprecated message such as
if not es.indices.exists(index="adn"):
response = es.indices.create(
index="adn",
# body=icd10adn,
# document=icd10adn,
mappings=icd10adn,
ignore=400 # ignore 400 already exists code
)
Using this caused the same deprecated message to be displayed.
Steps to reproduce:
Take this python code...
if not es.indices.exists(index="alive"):
# Note: i am not able to get the deprecated message to disappear.
# The information at Deprecation warnings in 7.15.0 pre-releases · Issue #1698 · elastic/elasticsearch-py · GitHub is too vague for me to
# understand how to code around not using the body key value.
# load the alive index with settings and mappings
#config_alive_index = load_json('../config/icd10alive.json')
response = es.indices.create(
index="alive",
body=icd10alive,
# document=icd10alive,
# mappings=icd10alive,
ignore=400 # ignore 400 already exists code
)
get this message...
mnt/isilon/opt/python/bin/python3 ICD10Import.py --feed TEST --log DEBUG
/mnt/isilon/SCRIPTS/bin/ICD10Import.py:310: DeprecationWarning: The 'body' parameter is deprecated for the 'create' API and will be removed in a future version. Instead use API parameters directly. See Deprecation warnings in 7.15.0 pre-releases · Issue #1698 · elastic/elasticsearch-py · GitHub for more information
change the above code to
if not es.indices.exists(index="alive"):
# Note: i am not able to get the deprecated message to disappear.
# The information at Deprecation warnings in 7.15.0 pre-releases · Issue #1698 · elastic/elasticsearch-py · GitHub is too vague for me to
# understand how to code around not using the body key value.
# load the alive index with settings and mappings
#config_alive_index = load_json('../config/icd10alive.json')
response = es.indices.create(
# index="alive",
# body=icd10alive,
document=icd10alive,
# mappings=icd10alive,
ignore=400 # ignore 400 already exists code
)
and then I get this error...
Traceback (most recent call last):
File "/mnt/isilon/SCRIPTS/bin/ICD10Import.py", line 573, in
main()
File "/mnt/isilon/SCRIPTS/bin/ICD10Import.py", line 317, in main
response = es.indices.create(
File "/mnt/isilon/opt/python/lib/python3.10/site-packages/Elasticsearch/client/utils.py", line 301, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
TypeError: IndicesClient.create() got an unexpected keyword argument 'document'
[ingmar@ip-172-31-30-59 bin]$ /mnt/isilon/opt/python/bin/python3 ICD10Import.py --feed TEST --log DEBUG
Traceback (most recent call last):
File "/mnt/isilon/SCRIPTS/bin/ICD10Import.py", line 574, in
main()
File "/mnt/isilon/SCRIPTS/bin/ICD10Import.py", line 310, in main
response = es.indices.create(
File "/mnt/isilon/opt/python/lib/python3.10/site-packages/Elasticsearch/client/utils.py", line 301, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
TypeError: IndicesClient.create() got an unexpected keyword argument 'document'
If I change the code to use mappings such as
if not es.indices.exists(index="alive"):
# Note: i am not able to get the deprecated message to disappear.
# The information at Deprecation warnings in 7.15.0 pre-releases · Issue #1698 · elastic/elasticsearch-py · GitHub is too vague for me to
# understand how to code around not using the body key value.
# load the alive index with settings and mappings
#config_alive_index = load_json('../config/icd10alive.json')
response = es.indices.create(
# index="alive",
# body=icd10alive,
# document=icd10alive,
mappings=icd10alive,
ignore=400 # ignore 400 already exists code
)
It works, but I still get the deprecated message.
What do I need to add to the stated code block in the above to get rid of the deprecated message, since the provided solution in
Deprecation warnings in 7.15.0 pre-releases · Issue #1698 · elastic/elasticsearch-py · GitHub doesn't seem to work to get rid of the message.
Thanks,
-Ingmar Thompson
Dish Network