DynamoDB 中的分页 [英] Pagination in DynamoDB

查看:16
本文介绍了DynamoDB 中的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在最大计数为 10 的 jsp 上显示搜索结果,并且它应该有一个分页来作为分页功能来回遍历.

I have a requirement for to show the search result on the jsp with maxcount of 10 and it should have a pagination to traverse back and forward as pagination functionality.

Dynamodb 有一个 lastevaluatedKey,但返回上一页无济于事,尽管我可以通过 lastevaluatedKey 转到下一个结果集.

Dynamodb has a lastevaluatedkey, but it doesn't help to go back to the previous page, though I can move to the next result set by the lastevaluatedKey.

有人可以帮忙吗?

我使用 Java SPRING 和 DynamoDB 作为堆栈.

I am using Java SPRING and DynamoDB as the stack.

谢谢萨提亚

推荐答案

要启用前进/后退,你只需要保持

To enable forward/backward, all you need is to keep

第一个键,即之前返回页面的第一条记录的hash key + sort key(如果要查询第一页则为null).

the first key, which is hash key + sort key of the first record of the previously returned page (null if you are about to query the first page).

最后一个key检索到的页面,也就是之前返回页面最后一条记录的hash key + sort key

the last key of the retrieved page, which is hash key + sort key of the last record of the previously returned page

然后要向前或向后导航,您需要在查询请求中传入以下参数:

Then to navigate forward or backward, you need to pass in below parameters in the query request:

Forward:最后一个key为ExclusiveStartKey,order=ascend

Backward:第一个key为ExclusiveStartKey,order = descend

我在 2016 年的一个项目中实现了这一点.DynamoDB 现在可能会提供一些类似的方便 API,但我不确定,因为我很长时间没有检查过 DynamoDB.

I have achieved this in a project in 2016. DynamoDB might provide some similar convenient APIs now, but I'm not sure as I haven't checked DynamoDB for a long time.

这篇关于DynamoDB 中的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆