From 3c0d04a3693fb70566f5ba7b045a24c0d5e955b1 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 5 Jun 2023 13:13:26 +0200 Subject: [PATCH] search fix --- src/search/forms.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/search/forms.py b/src/search/forms.py index f3bf0c024..1e680fa4f 100644 --- a/src/search/forms.py +++ b/src/search/forms.py @@ -3,7 +3,7 @@ # from django.apps import apps from django.conf import settings -from django.contrib.postgres.search import SearchHeadline, SearchRank, SearchQuery +from django.contrib.postgres.search import SearchHeadline, SearchQuery from django import forms from django.utils.translation import gettext_lazy as _ from catalogue.constants import LANGUAGES_3TO2 @@ -165,9 +165,7 @@ class SearchFilters(forms.Form): ).filter(search_vector=squery) books = books.exclude(ancestor__in=books) - snippets = qs['snippet'].annotate( - rank=SearchRank('search_vector', squery) - ).filter(rank__gt=0).order_by('-rank').annotate( + snippets = qs['snippet'].filter(search_vector=squery).annotate( headline=SearchHeadline( 'text', query, -- 2.20.1