-
Notifications
You must be signed in to change notification settings - Fork 173
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
base: master
Are you sure you want to change the base?
Conversation
950d3ae
to
970c92f
Compare
@@ -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') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated ✅
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]