Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elastic search search_after pagination #4473

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

hamza-56
Copy link
Contributor

@hamza-56 hamza-56 commented Oct 23, 2024

Testing instructions:

GET /api/v1/search/all/

  • page_size parameter limits the number of results returned.
  • search_after parameter enables pagination by returning results that appear after a specified document.

Example:

GET http://localhost:18381/api/v1/search/all/?page_size=1&search_after=[1728521062000,%22program:0b41be9d-10eb-4e10-ba2e-b2e47479e7b9%22]

@hamza-56 hamza-56 self-assigned this Oct 23, 2024
@@ -1,4 +1,4 @@
BASE_SEARCH_INDEX_FIELDS = ('aggregation_key', 'content_type', 'text')
BASE_SEARCH_INDEX_FIELDS = ('aggregation_key', 'aggregation_uuid', 'content_type', 'text', 'sort')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this impact v1, considering this constant will be used there too?

Copy link
Contributor Author

@hamza-56 hamza-56 Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-11-29 at 5 56 07 AM

Yes, as a result of this change, the aggregation_uuid is now included in the response of /api/v1/search/all/.

@@ -84,3 +84,32 @@ def _clone(self, klass=None, using=None, index=None, doc_type=None):
clone.aggs._params = {'aggs': self.aggs._params['aggs'].copy()}

return clone


class SearchAfterSearch(FacetedSearch):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a docstring for the class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ✅

@@ -99,6 +101,41 @@ class CustomPageNumberPagination(PageNumberPagination):
page_size_query_param = 'page_size'


class CustomSearchAfterPagination(PageNumberPagination):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this can be renamed to SearchAfterPagination. Custom does not make sense in the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated ✅

@hamza-56 hamza-56 marked this pull request as ready for review November 29, 2024 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants