diff --git a/wikipedia/challenges/common/esql-full-text-functions.json b/wikipedia/challenges/common/esql-full-text-functions.json index 9d98d04d8..952029d56 100644 --- a/wikipedia/challenges/common/esql-full-text-functions.json +++ b/wikipedia/challenges/common/esql-full-text-functions.json @@ -46,6 +46,20 @@ "time-period": {{ standalone_search_time_period | default(300) | int }}, "warmup-time-period": {{ standalone_search_warmup_time_period | default(10) | int }} }, +{ + "name": "standalone-esql-match-phrase-search", + "operation": "query-esql-match-phrase-search", + "clients": {{ standalone_search_clients | default(20) | int }}, + "time-period": {{ standalone_search_time_period | default(300) | int }}, + "warmup-time-period": {{ initial_indexing_bulk_warmup_time_period | default(40) | int }} +}, +{ + "name": "standalone-query-match-phrase-search", + "operation": "query-match-phrase-search", + "clients": {{ standalone_search_clients | default(20) | int }}, + "time-period": {{ standalone_search_time_period | default(300) | int }}, + "warmup-time-period": {{ standalone_search_warmup_time_period | default(10) | int }} +}, { "name": "standalone-esql-qstr-search", "operation": "query-esql-qstr-search", diff --git a/wikipedia/operations/default.json b/wikipedia/operations/default.json index a218ddcde..407710d16 100644 --- a/wikipedia/operations/default.json +++ b/wikipedia/operations/default.json @@ -172,6 +172,22 @@ "size" : {{ query_string_search_page_size | default(20) | int }}, "search-fields" : "{{ query_string_search_fields | default("*") }}" }, +{ + "name": "query-match-phrase-search", + "operation-type": "search", + "param-source": "query-search", + "query-type": "match_phrase", + "size" : {{ query_string_search_page_size | default(20) | int }}, + "search-fields" : "{{ query_string_search_fields | default("*") }}" +}, +{ + "name": "query-esql-match-phrase-search", + "operation-type": "esql", + "param-source": "esql-search", + "query-type": "match_phrase", + "size" : {{ query_string_search_page_size | default(20) | int }}, + "search-fields" : "{{ query_string_search_fields | default("*") }}" +}, { "name": "query-kql-search", "operation-type": "search", diff --git a/wikipedia/track.py b/wikipedia/track.py index 7f43e82de..f60ef6d26 100644 --- a/wikipedia/track.py +++ b/wikipedia/track.py @@ -234,6 +234,8 @@ def params(self): query_body = f'KQL("{ self._search_fields }:{ query }")' elif self._query_type == "term": query_body = f'TERM(title, "{ query }") OR TERM(content, "{ query }")' + elif self._query_type == "match_phrase": + query_body = f'MATCH_PHRASE(title, "{ query }") OR MATCH_PHRASE(content, "{ query }")' else: raise ValueError("Unknown query type: " + self._query_type) @@ -261,11 +263,13 @@ def params(self): elif self._query_type == "kql": query_body = {"kql": {"query": f'{ self._params["search-fields"] }:"{ query }"'}} elif self._query_type == "match": - query_body = {"match": {"content": query}} + query_body = {"bool": {"should": [{"match": {"title": query}}, {"match": {"content": query}}]}} elif self._query_type == "multi_match": query_body = {"bool": {"should": [{"match": {"title": query}}, {"match": {"content": query}}]}} elif self._query_type == "term": query_body = {"bool": {"should": [{"term": {"title": query}}, {"term": {"content": query}}]}} + elif self._query_type == "match_phrase": + query_body = {"bool": {"should": [{"match_phrase": {"title": query}}, {"match_phrase": {"content": query}}]}} else: raise ValueError("Unknown query type: " + self._query_type)