Annotation and filtering order

This commit is contained in:
Mouse Reeve 2021-06-26 18:55:09 -07:00
parent 8844e46259
commit 62b6bfe1ee

View file

@ -143,8 +143,9 @@ def search_title_author(query, min_confidence, *filters):
"""searches for title and author"""
query = SearchQuery(query, config="simple") | SearchQuery(query, config="english")
results = (
models.Edition.objects.annotate(rank=SearchRank(F("search_vector"), query))
.filter(*filters, search_vector=query, rank__gt=min_confidence)
models.Edition.objects.filter(*filters, search_vector=query)
.annotate(rank=SearchRank(F("search_vector"), query))
.filter(rank__gt=min_confidence)
.order_by("-rank")
)