mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 04:19:15 +02:00
Resolve "Switch to proper full-text-search system"
This commit is contained in:
parent
8556f137b1
commit
20311344d7
7 changed files with 159 additions and 8 deletions
|
@ -84,11 +84,21 @@ def get_fts_query(query_string, fts_fields=["body_text"], model=None):
|
|||
fk_field = model._meta.get_field(fk_field_name)
|
||||
related_model = fk_field.related_model
|
||||
subquery = related_model.objects.filter(
|
||||
**{lookup: SearchQuery(query_string, search_type="raw")}
|
||||
**{
|
||||
lookup: SearchQuery(
|
||||
query_string, search_type="raw", config="english_nostop"
|
||||
)
|
||||
}
|
||||
).values_list("pk", flat=True)
|
||||
new_query = Q(**{"{}__in".format(fk_field_name): list(subquery)})
|
||||
else:
|
||||
new_query = Q(**{field: SearchQuery(query_string, search_type="raw")})
|
||||
new_query = Q(
|
||||
**{
|
||||
field: SearchQuery(
|
||||
query_string, search_type="raw", config="english_nostop"
|
||||
)
|
||||
}
|
||||
)
|
||||
query = utils.join_queries_or(query, new_query)
|
||||
|
||||
return query
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue