Skip to content

Commit

Permalink
Accept Terms value to be any iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
Roxane committed Aug 22, 2024
1 parent b762aae commit dae98b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions elasticsearch_dsl/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@ class Term(Query):
class Terms(Query):
name = "terms"

def _setattr(self, name, value):
super()._setattr(name, list(value))


class TermsSet(Query):
name = "terms_set"
Expand Down
9 changes: 9 additions & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ def test_term_to_dict() -> None:
assert {"term": {"_type": "article"}} == query.Term(_type="article").to_dict()


def test_terms_to_dict() -> None:
assert {"terms": {"_type": ["article", "section"]}} == query.Terms(
_type=["article", "section"]
).to_dict()
assert {"terms": {"_type": ["article", "section"]}} == query.Terms(
_type=("article", "section")
).to_dict()


def test_bool_to_dict() -> None:
bool = query.Bool(must=[query.Match(f="value")], should=[])

Expand Down

0 comments on commit dae98b3

Please sign in to comment.