Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-gray-tangent committed Jul 17, 2024
1 parent 07f0532 commit 4111ac2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/general/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = (
Expand Down

0 comments on commit 4111ac2

Please sign in to comment.