Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Philipp Wolfer
funkwhale
Commits
b1ae13ab
Commit
b1ae13ab
authored
Aug 27, 2020
by
Agate
💬
Browse files
Fixed full-text search
parent
1d36df3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/common/search.py
View file @
b1ae13ab
...
...
@@ -59,13 +59,19 @@ def get_query(query_string, search_fields):
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
):
search_type
=
"
plain
"
search_type
=
"
raw
"
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
:
query_string
=
remove_chars
(
query_string
,
[
'"'
,
"&"
,
"("
,
")"
,
"!"
,
"'"
])
parts
=
query_string
.
replace
(
":"
,
""
).
split
(
" "
)
parts
=
[
"{}:*"
.
format
(
p
)
for
p
in
parts
if
p
]
if
not
parts
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment