pagination question on appsync to elasticsearch
Something bothers me here, in that AppSync connected to ElasticSearch and I need to use pagination. I see AppSync returns a next token which sound great, but how does it handle a user that wants to jump to the 6th page of content. How is that handled?
I also did a little testing in ElasticSearch and pagination looks to be controlled by 2 values; size and from. These remind me of limit and offset in SQL. So would it be better to just pass in a size and page number to the query than to make use of the next token?
AppSync can use either cursor-based or offset-based pagination. At AppSync, we generally lean toward cursor-based pagination as it's more ideal for real-time data where the ordering of records might change. (Useful explanation of advantages / disadvantages of Cursor-Based over Offset-based pagination: https://www.sitepoint.com/paginating-real-time-data-cursor-based-pagination/) It sounds like in your use case, you'll want to simply use offset-based pagination, which can be accomplished using the size and from attributes in the elasticsearch query, as you mentioned. You can pass size and from args from your graphql query into your elasticsearch query.
Aaron,
Thanks for the reply. I did go with the offset style as that just made more sense. I will need to look at that url you posted to have a better understanding of the pros/cons of each.
Following up to this. You can use the Elasticsearch Search After APIs to implement cursor based pagination on data in Elasticsearch. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-search-after for more information.
Relevant questions
Using Appsync with Redshift?
asked 4 months agoStrict transport security header on appsync responses
asked 2 months agoGreengrass V2 have component call appsync endpoint
asked 3 months agoAWS Amplify - Circular dependency in PostConfirm when access to AppSync is needed
asked 2 months agoConnecting AppSync with Redshift via Data API
asked a year agoProtect AWS Appsync APIs end point from public internet, restrict it to be accessible from Service deployed inside vpc
Accepted Answerasked 5 months agoHow to get connection duration metric from logs for AppSync subscription?
asked 15 days agoAppsync HTTP resolver supported content types
asked 2 years agopagination question on appsync to elasticsearch
Accepted Answerasked 3 years agoHow do I set up an AWS Amplify project to query an existing AWS AppSync API?
asked a month ago