Skip to content
Merged
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
4 changes: 4 additions & 0 deletions elasticsearch_dsl/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ class SpanWithin(Query):


# core queries
class CombinedFields(Query):
name = "combined_fields"


class Common(Query):
name = "common"

Expand Down
28 changes: 28 additions & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,34 @@ def test_empty_Q_is_match_all():
assert query.MatchAll() == q


def test_combined_fields_to_dict():
assert {
"combined_fields": {
"query": "this is a test",
"fields": ["name", "body", "description"],
"operator": "and",
},
} == query.CombinedFields(
query="this is a test",
fields=["name", "body", "description"],
operator="and",
).to_dict()


def test_combined_fields_to_dict_extra():
assert {
"combined_fields": {
"query": "this is a test",
"fields": ["name", "body^2"],
"operator": "or",
},
} == query.CombinedFields(
query="this is a test",
fields=["name", "body^2"],
operator="or",
).to_dict()


def test_match_to_dict():
assert {"match": {"f": "value"}} == query.Match(f="value").to_dict()

Expand Down