Commit aba42074 authored by Skia's avatar Skia

core: improve search index with 'autocomplete'

parent 65e0b15b
Pipeline #1624 passed with stage
in 9 minutes and 51 seconds
......@@ -31,6 +31,7 @@ from core.models import User
class UserIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
auto = indexes.EdgeNgramField(use_template=True)
def get_model(self):
return User
......
{{ object.first_name }}
{{ object.last_name }}
{{ object.nick_name }}
......@@ -71,7 +71,7 @@ def notification(request, notif_id):
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]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment