Skip to content

Commit 11bccf8

Browse files
ArtemBernatskyyhonzakral
authored andcommitted
Fixed deprecation - "field [exclude] used, expected [excludes] instead"
1 parent ab1ec5e commit 11bccf8

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

docs/search_dsl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ If you need to limit the fields being returned by elasticsearch, use the
462462
# don't return any fields, just the metadata
463463
s = s.source(False)
464464
# explicitly include/exclude fields
465-
s = s.source(include=["title"], exclude=["user.*"])
465+
s = s.source(includes=["title"], excludes=["user.*"])
466466
# reset the field selection
467467
s = s.source(None)
468468

elasticsearch_dsl/search.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,19 +478,19 @@ def source(self, fields=None, **kwargs):
478478
:arg fields: wildcard string, array of wildcards, or dictionary of includes and excludes
479479
480480
If ``fields`` is None, the entire document will be returned for
481-
each hit. If fields is a dictionary with keys of 'include' and/or
482-
'exclude' the fields will be either included or excluded appropriately.
481+
each hit. If fields is a dictionary with keys of 'includes' and/or
482+
'excludes' the fields will be either included or excluded appropriately.
483483
484484
Calling this multiple times with the same named parameter will override the
485485
previous values with the new ones.
486486
487487
Example::
488488
489489
s = Search()
490-
s = s.source(include=['obj1.*'], exclude=["*.description"])
490+
s = s.source(includes=['obj1.*'], excludes=["*.description"])
491491
492492
s = Search()
493-
s = s.source(include=['obj1.*']).source(exclude=["*.description"])
493+
s = s.source(includes=['obj1.*']).source(excludes=["*.description"])
494494
495495
"""
496496
s = self._clone()

test_elasticsearch_dsl/test_search.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,32 +421,32 @@ def test_source():
421421

422422
assert {
423423
'_source': {
424-
'include': ['foo.bar.*'],
425-
'exclude': ['foo.one']
424+
'includes': ['foo.bar.*'],
425+
'excludes': ['foo.one']
426426
}
427-
} == search.Search().source(include=['foo.bar.*'], exclude=['foo.one']).to_dict()
427+
} == search.Search().source(includes=['foo.bar.*'], excludes=['foo.one']).to_dict()
428428

429429
assert {
430430
'_source': False
431431
} == search.Search().source(False).to_dict()
432432

433433
assert {
434434
'_source': ['f1', 'f2']
435-
} == search.Search().source(include=['foo.bar.*'], exclude=['foo.one']).source(['f1', 'f2']).to_dict()
435+
} == search.Search().source(includes=['foo.bar.*'], excludes=['foo.one']).source(['f1', 'f2']).to_dict()
436436

437437
def test_source_on_clone():
438438
assert {
439439
'_source': {
440-
'include': ['foo.bar.*'],
441-
'exclude': ['foo.one']
440+
'includes': ['foo.bar.*'],
441+
'excludes': ['foo.one']
442442
},
443443
'query': {
444444
'bool': {
445445
'filter': [{'term': {'title': 'python'}}],
446446
}
447447
}
448-
} == search.Search().source(include=['foo.bar.*']).\
449-
source(exclude=['foo.one']).\
448+
} == search.Search().source(includes=['foo.bar.*']).\
449+
source(excludes=['foo.one']).\
450450
filter('term', title='python').to_dict()\
451451

452452
assert {'_source': False,
@@ -459,8 +459,8 @@ def test_source_on_clone():
459459

460460
def test_source_on_clear():
461461
assert {
462-
} == search.Search().source(include=['foo.bar.*']).\
463-
source(include=None, exclude=None).to_dict()
462+
} == search.Search().source(includes=['foo.bar.*']).\
463+
source(includes=None, excludes=None).to_dict()
464464

465465
def test_suggest_accepts_global_text():
466466
s = search.Search.from_dict({

0 commit comments

Comments
 (0)