Update match query
@@ -133,8 +133,17 @@ class PageSearchBase(RTDFacetedSearch):
"""Manipulates query to support nested query."""
search = search.highlight_options(**self._common_highlight_options)
+ all_queries = []
+
# match query for the title (of the page) field.
- match_title_query = Match(title=query)
+ for operator in self.operators:
+ all_queries.append(
+ SimpleQueryString(
+ query=query,
+ fields=self.fields,
+ default_operator=operator
+ )
+ )
# nested query for search in sections
sections_nested_query = self.generate_nested_query(
@@ -168,13 +177,10 @@ class PageSearchBase(RTDFacetedSearch):
}
)
- final_query = Bool(should=[
- match_title_query,
- sections_nested_query,
- domains_nested_query,
- ])
-
+ all_queries.extend([sections_nested_query, domains_nested_query])
+ final_query = Bool(should=all_queries)
search = search.query(final_query)
+
return search
def generate_nested_query(self, query, path, fields, inner_hits):
