Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
404b825d
Commit
404b825d
authored
Dec 05, 2018
by
Sli
Committed by
Skia
Dec 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forum: make search fuzzy
parent
286ba91c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
1 deletion
+6
-1
core/search_indexes.py
core/search_indexes.py
+1
-0
core/templates/search/indexes/forum/forummessage_auto.txt
core/templates/search/indexes/forum/forummessage_auto.txt
+4
-0
forum/views.py
forum/views.py
+1
-1
No files found.
core/search_indexes.py
View file @
404b825d
...
...
@@ -59,6 +59,7 @@ class UserOnlySignalProcessor(signals.BaseSignalProcessor):
class
ForumMessageIndex
(
indexes
.
SearchIndex
,
indexes
.
Indexable
):
text
=
indexes
.
CharField
(
document
=
True
,
use_template
=
True
)
auto
=
indexes
.
EdgeNgramField
(
use_template
=
True
)
def
get_model
(
self
):
return
ForumMessage
core/templates/search/indexes/forum/forummessage_auto.txt
0 → 100644
View file @
404b825d
{{ object.topic }}
{{ object.title }}
{{ object.message }}
{{ object.author }}
forum/views.py
View file @
404b825d
...
...
@@ -47,7 +47,7 @@ class ForumSearchView(ListView):
def
get_queryset
(
self
):
query
=
self
.
request
.
GET
.
get
(
"query"
,
""
)
q
=
SearchQuerySet
().
models
(
ForumMessage
).
filter_or
(
text__contains
=
query
)
q
=
SearchQuerySet
().
models
(
ForumMessage
).
autocomplete
(
auto
=
query
)
return
[
r
.
object
for
r
in
q
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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