diff --git a/src/extended_search/managers/query_builder.py b/src/extended_search/managers/query_builder.py index 1960a3510..73880b4ce 100644 --- a/src/extended_search/managers/query_builder.py +++ b/src/extended_search/managers/query_builder.py @@ -6,6 +6,7 @@ from wagtail.search.query import Boost, Fuzzy, Phrase, PlainText, SearchQuery from extended_search.backends.query import Nested, OnlyFields +from extended_search.managers import get_indexed_field_name from extended_search.settings import extended_search_settings as search_settings from extended_search.types import AnalysisType, SearchQueryType @@ -128,7 +129,8 @@ def _get_searchquery_for_query_field_querytype_analysistype( analysis_type, ) - return OnlyFields(Boost(query, boost), fields=[base_field_name]) + field_name = get_indexed_field_name(base_field_name, analysis_type) + return OnlyFields(Boost(query, boost), fields=[field_name]) @classmethod def _combine_queries(cls, q1: Optional[SearchQuery], q2: Optional[SearchQuery]): diff --git a/src/extended_search/tests/test_querybuilder.py b/src/extended_search/tests/test_querybuilder.py index aef009428..2ff9f6200 100644 --- a/src/extended_search/tests/test_querybuilder.py +++ b/src/extended_search/tests/test_querybuilder.py @@ -166,7 +166,7 @@ def test_get_searchquery_for_etc_uses_submethods(self, mocker): {}, ) assert isinstance(result, OnlyFields) - assert result.fields == ["title"] + assert result.fields == ["title_explicit"] subquery = result.subquery assert isinstance(subquery, Boost) assert subquery.boost == 333.33 @@ -376,7 +376,7 @@ def test_get_searchquery_for_etc_uses_submethods(self, mocker): {"parent_model_field": "foo"}, ) assert isinstance(result, OnlyFields) - assert result.fields == ["foo.title"] + assert result.fields == ["foo.title_explicit"] subquery = result.subquery assert isinstance(subquery, Boost) assert subquery.boost == 333.33