Skip to content

Commit fcbc519

Browse files
authored
Use the keyword field for tags in related query (#3346)
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent fd61b0c commit fcbc519

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

api/api/controllers/elasticsearch/related.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def related_media(uuid: str, index: str, filter_dead: bool) -> list[Hit]:
5050
# Only use the first 10 tags
5151
if tags:
5252
tags = [tag["name"] for tag in tags[:10]]
53-
related_query["should"].append(Q("terms", tags__name=tags))
53+
related_query["should"].append(Q("terms", tags__name__keyword=tags))
5454

5555
# Exclude the dynamically disabled sources.
5656
if excluded_providers_query := get_excluded_providers_query():

api/test/unit/controllers/elasticsearch/test_related.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_related_media(
8080
],
8181
"should": [
8282
{"match": {"title": "Bird Nature Photo"}},
83-
{"terms": {"tags.name": ["bird"]}},
83+
{"terms": {"tags.name.keyword": ["bird"]}},
8484
],
8585
}
8686
},

0 commit comments

Comments
 (0)