mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 23:29:17 +02:00
Fix #1196: Fixed broken search when using (, " or & chars
This commit is contained in:
parent
6bd77f24d6
commit
0c25370fff
3 changed files with 5 additions and 19 deletions
|
@ -60,9 +60,11 @@ def get_query(query_string, search_fields):
|
|||
|
||||
|
||||
def get_fts_query(query_string, fts_fields=["body_text"], model=None):
|
||||
search_type = "plain"
|
||||
if query_string.startswith('"') and query_string.endswith('"'):
|
||||
# we pass the query directly to the FTS engine
|
||||
query_string = query_string[1:-1]
|
||||
search_type = "raw"
|
||||
else:
|
||||
parts = query_string.replace(":", "").split(" ")
|
||||
parts = ["{}:*".format(p) for p in parts if p]
|
||||
|
@ -86,7 +88,7 @@ def get_fts_query(query_string, fts_fields=["body_text"], model=None):
|
|||
subquery = related_model.objects.filter(
|
||||
**{
|
||||
lookup: SearchQuery(
|
||||
query_string, search_type="raw", config="english_nostop"
|
||||
query_string, search_type=search_type, config="english_nostop"
|
||||
)
|
||||
}
|
||||
).values_list("pk", flat=True)
|
||||
|
@ -95,7 +97,7 @@ def get_fts_query(query_string, fts_fields=["body_text"], model=None):
|
|||
new_query = Q(
|
||||
**{
|
||||
field: SearchQuery(
|
||||
query_string, search_type="raw", config="english_nostop"
|
||||
query_string, search_type=search_type, config="english_nostop"
|
||||
)
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue