Skip to content

Commit 667106d

Browse files
Merge pull request #126 from kitconcept/kid/suggest-include-images
Suggest: include images by default
2 parents f7cc688 + f7de0f7 commit 667106d

3 files changed

Lines changed: 25 additions & 8 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Suggestions include images by default: the results page finds images, so the type-ahead does too (team decision from the intranet ticket 570 review). The built-in exclusion list keeps only fragment/redirect types (Glossary, FAQ, Link). @reebalazs

backend/src/kitconcept/solr/services/suggest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def query_suggest(self, query):
5454
)
5555
extra_fq = extra_conditions.query_list()
5656
# An explicit type filter wins over the built-in exclusions:
57-
# the exclusion list keeps noise (e.g. images) out of the
58-
# default suggestions, but a user who filters for exactly such
59-
# a type must see it.
57+
# the exclusion list keeps fragment/redirect types (FAQ items,
58+
# glossary entries, links) out of the default suggestions, but
59+
# a user who filters for exactly such a type must see it.
6060
has_type_filter = any(
6161
row and row[0] in ("portal_type", "Type")
6262
for row in extra_conditions.config
@@ -66,8 +66,11 @@ def query_suggest(self, query):
6666
[]
6767
if has_type_filter
6868
else [
69+
# Images are deliberately NOT excluded: the results
70+
# page finds them, so the type-ahead must too (team
71+
# decision, intranet ticket 570 review).
6972
(
70-
"-portal_type:Image -portal_type:Glossary -portal_type:FAQ "
73+
"-portal_type:Glossary -portal_type:FAQ "
7174
"-portal_type:(FAQ Item) -portal_type:(FAQ Category) "
7275
"-portal_type:Link"
7376
)

backend/tests/services/suggest/test_suggest.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ def func(data, index: int) -> dict:
5050
class TestSuggestDefaultBaseSearch(TestSuggestDefault):
5151
url = "/@solr-suggest?query=chomsky"
5252
expected_result: ClassVar[list] = [
53+
{
54+
# images are suggested by default, like on the results page
55+
"@id": "http://localhost:59793/plone/noamchomsky",
56+
"@type": "Image",
57+
"description": "",
58+
"title": "Prof. Dr. Noam Chomsky",
59+
"type_title": "Image",
60+
},
5361
{
5462
"@id": "http://localhost:59793/plone/mydocument",
5563
"@type": "Document",
@@ -124,9 +132,10 @@ def test_only_filtered_type(self, get_suggest_result_path):
124132

125133

126134
class TestSuggestExtraConditionsTypeOverridesExclusion(TestSuggestDefault):
127-
"""An explicit type filter wins over the built-in type exclusion
128-
list: Image is normally excluded from suggestions, but a user who
129-
filters for images must see them."""
135+
"""An explicit type filter restricts the suggestions to the
136+
selected type - for images that means only the image is left (and
137+
for the types still on the built-in exclusion list, the filter
138+
would override the exclusion)."""
130139

131140
url = "/@solr-suggest?query=chomsky&extra_conditions=" + encode_conditions([
132141
["portal_type", "string", {"in": ["Image"]}]
@@ -159,7 +168,11 @@ class TestSuggestExtraConditionsDateRange(TestSuggestDefault):
159168

160169
def test_recent_content_kept(self, get_suggest_result_path):
161170
paths = [get_suggest_result_path(item) for item in self.data["suggestions"]]
162-
assert paths == ["/plone/mydocument", "/plone/mynews"]
171+
assert paths == [
172+
"/plone/noamchomsky",
173+
"/plone/mydocument",
174+
"/plone/mynews",
175+
]
163176

164177

165178
class TestSuggestExtraConditionsDateRangePast(TestSuggestDefault):

0 commit comments

Comments
 (0)