Skip to content

Accepts boost param on Terms #1904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion elasticsearch_dsl/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,10 @@ class Terms(Query):
name = "terms"

def _setattr(self, name: str, value: Any) -> None:
super()._setattr(name, list(value))
if name != "boost":
value = list(value)

super()._setattr(name, value)


class TermsSet(Query):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ def test_terms_to_dict() -> None:
).to_dict()


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


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

Expand Down
Loading