Correctly order LMOTFY endpoint

Ordering by "relevance" actually yields the least relevant results first. Remove ordering and assume the most relevant is what's needed.
This commit is contained in:
Jake Howard 2022-10-31 20:39:36 +00:00
parent 87bb14482e
commit 66156f2be7
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 2 additions and 5 deletions

View file

@ -17,6 +17,6 @@ class WagtailSearchFilter(SearchFilter):
return queryset.annotate(relevance=Value(0)).none()
filters, query = parse_query_string(search_query)
results = queryset.search(query).annotate_score("relevance")
results = queryset.search(query, order_by_relevance=True)
return results.get_queryset()

View file

@ -2,7 +2,6 @@ from django.http import HttpResponseRedirect
from django.http.request import HttpRequest
from django.urls import reverse
from django.views.generic import RedirectView
from rest_framework.filters import OrderingFilter
from rest_framework.generics import ListAPIView
from rest_framework.response import Response
from rest_framework.views import APIView
@ -42,10 +41,8 @@ class LMOTFYAPIView(ListAPIView):
Let Me Orange That For You
"""
filter_backends = [filters.WagtailSearchFilter, OrderingFilter]
filter_backends = [filters.WagtailSearchFilter]
serializer_class = serializers.LMOTFYSerializer
ordering_fields = ["title", "date", "relevance"]
ordering = ["relevance"]
pagination_class = CustomPageNumberPagination
def get_queryset(self) -> PageQuerySet: