Skip to content

Commit

Permalink
Change "exact match boost" implementation to use a match_phrase query…
Browse files Browse the repository at this point in the history
… in should #4960

I have added support for "match_pharse"
and also removed variable quotes_stripped it's not needed now.
  • Loading branch information
dryruffian committed Sep 23, 2024
1 parent cf225ff commit 409a45c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/api/controllers/search_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ def build_search_query(

search_queries["must"].append(Q("simple_query_string", **base_query_kwargs))
# Boost exact matches on the title
quotes_stripped = query.replace('"', "")

exact_match_boost = Q(
"simple_query_string",
flags=DEFAULT_SQS_FLAGS,
fields=["title"],
query=f"{quotes_stripped}",
boost=10000,
"match_phrase",
title = {
"query":query,
"boost":10000
}
)
search_queries["should"].append(exact_match_boost)
else:
Expand Down

0 comments on commit 409a45c

Please sign in to comment.