# DeprecationWarning: The 'body' parameter is deprecated for the 'index' API and will be removed in a future version

**URL:** <https://discuss.elastic.co/t/deprecationwarning-the-body-parameter-is-deprecated-for-the-index-api-and-will-be-removed-in-a-future-version/291876>\
**Category:** Elasticsearch\
**Created:** [December 14, 2021, 10:15pm UTC](https://discuss.elastic.co/t/deprecationwarning-the-body-parameter-is-deprecated-for-the-index-api-and-will-be-removed-in-a-future-version/291876 "2021-12-14T22:15:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ingmar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ingmar/32/101396_2.png) [@ingmar](https://discuss.elastic.co/u/ingmar)\
**Post date:** [December 14, 2021, 10:15pm UTC](https://discuss.elastic.co/t/deprecationwarning-the-body-parameter-is-deprecated-for-the-index-api-and-will-be-removed-in-a-future-version/291876/1 "2021-12-14T22:15:06Z")

</div>

**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](https://github.com/elastic/elasticsearch-py/issues/1698) 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](https://github.com/elastic/elasticsearch-py/issues/1698) 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](https://github.com/elastic/elasticsearch-py/issues/1698) doesn't seem to work?  
I saw another suggestion in [https://discuss.elastic.co/](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](https://github.com/elastic/elasticsearch-py/issues/1698) 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](https://github.com/elastic/elasticsearch-py/issues/1698) 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](https://github.com/elastic/elasticsearch-py/issues/1698) 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](https://github.com/elastic/elasticsearch-py/issues/1698) 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](https://github.com/elastic/elasticsearch-py/issues/1698) doesn't seem to work to get rid of the message.

Thanks,  
-Ingmar Thompson  
Dish Network

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 11, 2022, 10:16pm UTC](https://discuss.elastic.co/t/deprecationwarning-the-body-parameter-is-deprecated-for-the-index-api-and-will-be-removed-in-a-future-version/291876/2 "2022-01-11T22:16:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
