Skip to content

Commit 7beb8fa

Browse files
committed
Fix DeprecationWarning's from elasticsearch-py.
1 parent 620ddc8 commit 7beb8fa

File tree

7 files changed

+29
-17
lines changed

7 files changed

+29
-17
lines changed

Changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
Changelog
44
=========
55

6+
7.4.1 (?)
7+
------------------
8+
9+
* Fixed DeprecationWarning from elasticsearch-py (`#1558`_)
10+
11+
.. _#1558: https://github.com/elastic/elasticsearch-dsl-py/pull/1558
12+
613
7.4.0 (2021-07-15)
714
------------------
815

README

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,20 @@ Let's have a typical search request written directly as a ``dict``:
8080

8181
response = client.search(
8282
index="my-index",
83-
body={
84-
"query": {
83+
query={
8584
"bool": {
86-
"must": [{"match": {"title": "python"}}],
87-
"must_not": [{"match": {"description": "beta"}}],
88-
"filter": [{"term": {"category": "search"}}]
85+
"must": [{"match": {"title": "python"}}],
86+
"must_not": [{"match": {"description": "beta"}}],
87+
"filter": [{"term": {"category": "search"}}]
8988
}
90-
},
91-
"aggs" : {
89+
},
90+
aggs={
9291
"per_tag": {
93-
"terms": {"field": "tags"},
94-
"aggs": {
95-
"max_lines": {"max": {"field": "lines"}}
96-
}
92+
"terms": {"field": "tags"},
93+
"aggs": {
94+
"max_lines": {"max": {"field": "lines"}}
95+
}
9796
}
98-
}
9997
}
10098
)
10199

elasticsearch_dsl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
from .utils import AttrDict, AttrList, DslBase
8585
from .wrappers import Range
8686

87-
VERSION = (7, 2, 0)
87+
VERSION = (7, 4, 1)
8888
__version__ = VERSION
8989
__versionstr__ = ".".join(map(str, VERSION))
9090
__all__ = [

elasticsearch_dsl/document.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from fnmatch import fnmatch
2424

25+
import elasticsearch
2526
from elasticsearch.exceptions import NotFoundError, RequestError
2627
from six import add_metaclass, iteritems
2728

@@ -482,11 +483,17 @@ def save(
482483
doc_meta["if_primary_term"] = self.meta["primary_term"]
483484

484485
doc_meta.update(kwargs)
486+
487+
if elasticsearch.__version__ >= (7, 14, 0):
488+
key = 'document'
489+
else:
490+
key = 'body'
485491
meta = es.index(
486492
index=self._get_index(index),
487-
body=self.to_dict(skip_empty=skip_empty),
493+
**{key: self.to_dict(skip_empty=skip_empty)},
488494
**doc_meta
489495
)
496+
490497
# update meta information from ES
491498
for k in META_FIELDS:
492499
if "_" + k in meta:

elasticsearch_dsl/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def create(self, using=None, **kwargs):
277277
``Elasticsearch.indices.create`` unchanged.
278278
"""
279279
return self._get_connection(using).indices.create(
280-
index=self._name, body=self.to_dict(), **kwargs
280+
index=self._name, **self.to_dict(), **kwargs
281281
)
282282

283283
def is_closed(self, using=None):

elasticsearch_dsl/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def execute(self, ignore_cache=False):
712712
es = get_connection(self._using)
713713

714714
self._response = self._response_class(
715-
self, es.search(index=self._index, body=self.to_dict(), **self._params)
715+
self, es.search(index=self._index, **self.to_dict(), **self._params)
716716
)
717717
return self._response
718718

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from setuptools import find_packages, setup
2222

23-
VERSION = (7, 2, 0)
23+
VERSION = (7, 4, 1)
2424
__version__ = VERSION
2525
__versionstr__ = ".".join(map(str, VERSION))
2626

0 commit comments

Comments
 (0)