Skip to content

[ENG-7429] Add query syntax with `simple_query_string #862

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

Merged
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
18 changes: 10 additions & 8 deletions share/search/index_strategy/trovesearch_denorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,16 @@ def iri_boolparts(self) -> Iterator[tuple[str, dict]]:
def text_boolparts(self) -> Iterator[tuple[str, dict]]:
# text-based queries
for _text in self.searchtext:
yield 'must', self._exact_text_query(_text)
yield (
'must',
{
"simple_query_string": {
"query": _text.text,
"fields": [self._text_field_name(_path) for _path in _text.propertypath_set],
"default_operator": "AND"
}
}
)

def _presence_query(self, search_filter) -> dict:
return _any_query([
Expand Down Expand Up @@ -711,13 +720,6 @@ def _text_field_name(self, propertypath: Propertypath):
else f'{self.base_field}.text_by_propertypath.{_path_field_name(propertypath)}'
)

def _exact_text_query(self, textsegment: SearchText) -> dict:
# TODO: textsegment.is_openended (prefix query)
return _any_query([
{'match_phrase': {self._text_field_name(_path): {'query': textsegment.text}}}
for _path in textsegment.propertypath_set
])


@dataclasses.dataclass
class _CardsearchQueryBuilder:
Expand Down