diff --git a/app/general/filters.py b/app/general/filters.py index 2f75e070..e452aa4b 100644 --- a/app/general/filters.py +++ b/app/general/filters.py @@ -6,7 +6,7 @@ SearchRank, SearchVector, ) -from django.db.models import F, IntegerField, Q, Value +from django.db.models import F, IntegerField, Value from django_filters import ModelMultipleChoiceFilter, MultipleChoiceFilter from general.models import DocumentFile, Institution, Language, Project, Subject @@ -41,13 +41,14 @@ def filter_queryset(self, queryset): queryset = super().filter_queryset(queryset) search = self.form.cleaned_data.get("search", "").strip() + queue = SearchQuery(search) search_vector = SearchVector("title", weight="A") + SearchVector("description", weight="B") project_query = Project.objects.annotate( - search=SearchVector("name", weight="A") + SearchVector("description", weight="B") + search=SearchVector("name", weight="A") + SearchVector("description", weight="B"), + search_headline=SearchHeadline("description", queue), ).filter(search=SearchQuery(search)) - queue = SearchQuery(search) search_rank = SearchRank(F("search_vector"), queue) search_headline = SearchHeadline("document_data", queue) queryset = (