Skip to content

Commit

Permalink
Merge pull request #1715 from laws-africa/search-page-size
Browse files Browse the repository at this point in the history
ensure API and Vue concept of search page size aligns
  • Loading branch information
longhotsummer authored Feb 2, 2024
2 parents 4191414 + 1832c82 commit e852363
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions peachjam_search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
BaseSearchQueryBackend,
SimpleQueryStringQueryBackend,
)
from django_elasticsearch_dsl_drf.pagination import PageNumberPagination
from django_elasticsearch_dsl_drf.viewsets import BaseDocumentViewSet
from elasticsearch_dsl import DateHistogramFacet
from elasticsearch_dsl.connections import get_connection
Expand All @@ -36,6 +37,10 @@
CACHE_SECS = 15 * 60


class CustomPageNumberPagination(PageNumberPagination):
page_size = 10


class MultiFieldSearchQueryBackend(SimpleQueryStringQueryBackend):
"""Supports searching across multiple fields.
Expand Down Expand Up @@ -233,6 +238,8 @@ class DocumentSearchViewSet(BaseDocumentViewSet):
HighlightBackend,
]

pagination_class = CustomPageNumberPagination

# allowed and default ordering
ordering_fields = {"date": "date", "title": "title"}
ordering = ("_score", "date")
Expand Down

0 comments on commit e852363

Please sign in to comment.