Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
42
Issues
42
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
aba42074
Commit
aba42074
authored
Dec 05, 2018
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: improve search index with 'autocomplete'
parent
65e0b15b
Pipeline
#1624
passed with stage
in 9 minutes and 51 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
1 deletion
+5
-1
core/search_indexes.py
core/search_indexes.py
+1
-0
core/templates/search/indexes/core/user_auto.txt
core/templates/search/indexes/core/user_auto.txt
+3
-0
core/views/site.py
core/views/site.py
+1
-1
No files found.
core/search_indexes.py
View file @
aba42074
...
@@ -31,6 +31,7 @@ from core.models import User
...
@@ -31,6 +31,7 @@ from core.models import User
class
UserIndex
(
indexes
.
SearchIndex
,
indexes
.
Indexable
):
class
UserIndex
(
indexes
.
SearchIndex
,
indexes
.
Indexable
):
text
=
indexes
.
CharField
(
document
=
True
,
use_template
=
True
)
text
=
indexes
.
CharField
(
document
=
True
,
use_template
=
True
)
auto
=
indexes
.
EdgeNgramField
(
use_template
=
True
)
def
get_model
(
self
):
def
get_model
(
self
):
return
User
return
User
...
...
core/templates/search/indexes/core/user_auto.txt
0 → 100644
View file @
aba42074
{{ object.first_name }}
{{ object.last_name }}
{{ object.nick_name }}
core/views/site.py
View file @
aba42074
...
@@ -71,7 +71,7 @@ def notification(request, notif_id):
...
@@ -71,7 +71,7 @@ def notification(request, notif_id):
def
search_user
(
query
,
as_json
=
False
):
def
search_user
(
query
,
as_json
=
False
):
res
=
SearchQuerySet
()
.
models
(
User
)
.
filter_or
(
text__contains
=
query
)[:
20
]
res
=
SearchQuerySet
()
.
models
(
User
)
.
autocomplete
(
auto
=
query
)[:
20
]
return
[
r
.
object
for
r
in
res
]
return
[
r
.
object
for
r
in
res
]
...
...
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