Adapt forum search to xapian and improve query

This commit is contained in:
Antoine Bartuccio 2018-12-05 14:05:47 +01:00 committed by Skia
parent 9b8a881914
commit 286ba91c75
3 changed files with 5 additions and 2 deletions

View File

@ -27,7 +27,7 @@ from django.conf import settings
from django.utils.functional import SimpleLazyObject from django.utils.functional import SimpleLazyObject
from django.contrib.auth import get_user from django.contrib.auth import get_user
from django.contrib.auth.middleware import ( from django.contrib.auth.middleware import (
AuthenticationMiddleware as DjangoAuthenticationMiddleware AuthenticationMiddleware as DjangoAuthenticationMiddleware,
) )
module, klass = settings.AUTH_ANONYMOUS_MODEL.rsplit(".", 1) module, klass = settings.AUTH_ANONYMOUS_MODEL.rsplit(".", 1)

View File

@ -1 +1,4 @@
{{ object.topic }}
{{ object.title }}
{{ object.message }} {{ object.message }}
{{ object.author }}

View File

@ -47,7 +47,7 @@ class ForumSearchView(ListView):
def get_queryset(self): def get_queryset(self):
query = self.request.GET.get("query", "") query = self.request.GET.get("query", "")
q = SearchQuerySet().models(ForumMessage).filter(text=query) q = SearchQuerySet().models(ForumMessage).filter_or(text__contains=query)
return [r.object for r in q] return [r.object for r in q]