mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 08:39:24 +02:00
Fixed full-text search
This commit is contained in:
parent
1d36df3f69
commit
b1ae13ab0a
1 changed files with 8 additions and 2 deletions
|
@ -59,13 +59,19 @@ def get_query(query_string, search_fields):
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
|
def remove_chars(string, chars):
|
||||||
|
for char in chars:
|
||||||
|
string = string.replace(char, "")
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
def get_fts_query(query_string, fts_fields=["body_text"], model=None):
|
def get_fts_query(query_string, fts_fields=["body_text"], model=None):
|
||||||
search_type = "plain"
|
search_type = "raw"
|
||||||
if query_string.startswith('"') and query_string.endswith('"'):
|
if query_string.startswith('"') and query_string.endswith('"'):
|
||||||
# we pass the query directly to the FTS engine
|
# we pass the query directly to the FTS engine
|
||||||
query_string = query_string[1:-1]
|
query_string = query_string[1:-1]
|
||||||
search_type = "raw"
|
|
||||||
else:
|
else:
|
||||||
|
query_string = remove_chars(query_string, ['"', "&", "(", ")", "!", "'"])
|
||||||
parts = query_string.replace(":", "").split(" ")
|
parts = query_string.replace(":", "").split(" ")
|
||||||
parts = ["{}:*".format(p) for p in parts if p]
|
parts = ["{}:*".format(p) for p in parts if p]
|
||||||
if not parts:
|
if not parts:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue