mirror of
https://github.com/Alexander-D-Karpov/akarpov
synced 2024-11-22 01:36:33 +03:00
bug fixes
This commit is contained in:
parent
b4124d90bb
commit
1fb6219b7c
|
@ -12,16 +12,13 @@ def search_song(query):
|
||||||
search_query = ES_Q(
|
search_query = ES_Q(
|
||||||
"bool",
|
"bool",
|
||||||
should=[
|
should=[
|
||||||
# Boost for exact matches using a "bool" and "should" combination
|
|
||||||
ES_Q("bool", should=[ES_Q("match_phrase", name__exact=query)], boost=5),
|
ES_Q("bool", should=[ES_Q("match_phrase", name__exact=query)], boost=5),
|
||||||
ES_Q(
|
ES_Q(
|
||||||
"bool",
|
"bool",
|
||||||
should=[ES_Q("match_phrase", name__raw=query.lower())],
|
should=[ES_Q("match_phrase", name__raw=query.lower())],
|
||||||
boost=2.5,
|
boost=2.5,
|
||||||
),
|
),
|
||||||
# Standard matches
|
|
||||||
ES_Q("match", name__russian=query),
|
ES_Q("match", name__russian=query),
|
||||||
# Multi-match queries for various fields
|
|
||||||
ES_Q(
|
ES_Q(
|
||||||
"multi_match",
|
"multi_match",
|
||||||
query=query,
|
query=query,
|
||||||
|
@ -36,10 +33,6 @@ def search_song(query):
|
||||||
type="best_fields",
|
type="best_fields",
|
||||||
fuzziness="AUTO",
|
fuzziness="AUTO",
|
||||||
),
|
),
|
||||||
# Matching against meta fields
|
|
||||||
ES_Q("match", meta__lyrics=query, fuzziness="AUTO", boost=0.5),
|
|
||||||
ES_Q("match", meta__raw=query.lower(), fuzziness="AUTO", boost=0.5),
|
|
||||||
# Nested queries for authors and albums
|
|
||||||
ES_Q(
|
ES_Q(
|
||||||
"nested",
|
"nested",
|
||||||
path="authors",
|
path="authors",
|
||||||
|
@ -62,9 +55,8 @@ def search_song(query):
|
||||||
),
|
),
|
||||||
boost=2,
|
boost=2,
|
||||||
),
|
),
|
||||||
# Wildcard queries for partial matches
|
ES_Q("wildcard", name__raw=f"*{query.lower()}*", boost=0.5),
|
||||||
ES_Q("wildcard", name__raw=f"*{query.lower()}*"),
|
ES_Q("wildcard", meta__raw=f"*{query.lower()}*", boost=0.5),
|
||||||
ES_Q("wildcard", meta__raw=f"*{query.lower()}*"),
|
|
||||||
],
|
],
|
||||||
minimum_should_match=1,
|
minimum_should_match=1,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user