Skip to content

Commit

Permalink
DWPF-905 Fix explicit fields (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
CamLamb authored Nov 7, 2023
1 parent 41fbfd6 commit 56585fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/extended_search/managers/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]):
Expand Down
4 changes: 2 additions & 2 deletions src/extended_search/tests/test_querybuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 56585fb

Please sign in to comment.