我有一个包含视频信息的 DynamoDB 表。
目前“videoID”是主(哈希)键,“Category”是范围(排序)键。
我想要获取所有“类别”(范围键)的列表,以便用户可以从可用的视频类别之一中进行选择。
https://www.quora.com/What-are-some-good-ways-to-extract-one-single-column-from-a-DynamoDB-table
我读到,如果您修改了将属性“类别”更改为全局二级索引,您可以返回该 GSI 的项目。但我一直无法找到如何做到这一点。
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSIJavaDocumentAPI.html
所以我想这给了我三个问题:
有没有办法通过仅查询范围键来查找类别中的项目?
如果将类别更改为 GSI,我可以通过这种方式找到项目吗?
或
扫描整个表格是唯一的方法吗?
预先感谢您的帮助
最佳答案
Is the only way of doing it scanning the whole table?
-不,您可以实现 GSI 来避免它
Is there a way to do to find the items in Category by querying just the range key?
- 是的,如果您不想扫描整个表,那么您需要创建 GSI,其中类别为哈希。该 GSI 本身将充当一个表,您可以通过传递类别值来查询它。
If change Category to a GSI can I find the items that way?
-是的,您可以使用类别值在 GSI 上查询
I was reading that if you modified change the attribute "Category" to a global secondary index you can return the items for that GSI. But I have not been able to find how to do that.
-创建表时需要创建GSI,示例在您指定的链接中给出,完成后您可以查询该GSI
引用文献:http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html
关于java - DynamoDB 获取范围键或全局辅助的单列列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39864697/