是否可以对DynamoDB中的查询结果或扫描进行ORDER结果? [英] Is it possible to ORDER results with query or scan in DynamoDB?

查看:108
本文介绍了是否可以对DynamoDB中的查询结果或扫描进行ORDER结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在DynamoDB中使用查询或扫描API来对结果进行排序?

Is it possible to ORDER results with Query or Scan API in DynamoDB?

我需要知道DynamoDB是否具有SQL中的[ORDER BY'field']之类的东西查询?

I need to know if DynamoDB has something like [ORDER BY 'field'] from SQL queries?

谢谢。

推荐答案

但没有明确规定,订购显然可以用于许多现实世界中的用例,并且可以通过哈希和范围类型主键相应地:

Not explicitly, however, ordering is obviously needed for many real world use cases and can be modeled by means of the Hash and Range Type Primary Key accordingly:


在这种情况下,主键由两个属性组成。第一个
属性是hash属性,第二个是范围
属性。 Amazon DynamoDB在哈希
主键属性上构建无序哈希索引,并在范围主
键属性上构建排序范围索引 [强调我的]

然后您可以使用此范围索引通过请求项目查询API 的RangeKeyCondition 参数并指定向前或向后遍历(即排序方向)通过 ScanIndexForward 参数。

You can then use this range index to optionally request items via the RangeKeyCondition parameter of the Query API and specify forward or backward traversal of the index (i.e. the sort direction) via the ScanIndexForward parameter.

更新:按照具有本地二级索引的属性进行排序。

Update: You can order by an attribute with a local secondary index in the same way.

这篇关于是否可以对DynamoDB中的查询结果或扫描进行ORDER结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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