DynamoDB 在地图或列表类型上创建索引 [英] DynamoDB create index on map or list type

查看:21
本文介绍了DynamoDB 在地图或列表类型上创建索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 DynamoDB 中地图对象内的属性添加索引,但似乎找不到这样做的方法.这是支持的东西还是索引真的只允许在标量值上?围绕此的文档似乎非常稀少.我希望索引功能类似于 MongoDB,但到目前为止,我使用点语法引用属性来索引的方法还没有成功.感谢您提供任何帮助或其他信息.

I'm trying to add an index to an attribute inside of a map object in DynamoDB and can't seem to find a way to do so. Is this something that is supported or are indexes really only allowed on scalar values? The documentation around this seems to be quite sparse. I'm hoping that the indexing functionality is similar to MongoDB but so far the approaches I've taken of referencing the attribute to index using dot syntax has not been successful. Any help or additional info that can be provided is appreciated.

推荐答案

只能在顶级 JSON 属性上构建索引.此外,范围键必须是 DynamoDB 中的标量值(字符串、数字、二进制或布尔值之一).

Indexes can be built only on top-level JSON attributes. In addition, range keys must be scalar values in DynamoDB (one of String, Number, Binary, or Boolean).

来自 http://aws.amazon.com/dynamodb/faqs/:

问:在 DynamoDB 中查询 JSON 数据有什么不同吗?

Q: Is querying JSON data in DynamoDB any different?

没有.您可以创建全局二级索引或本地二级索引在任何顶级 JSON 元素上.例如,假设您存储了一个 JSON包含有关某人的以下信息的文件:名字、姓氏、邮政编码和他们所有朋友的列表.名字、姓氏和邮政编码将是顶级 JSON 元素.您可以创建一个索引,让您根据名字、姓氏进行查询姓名或邮政编码.好友列表不是顶级元素,因此,您无法索引朋友列表.想要查询更多的信息有关全局二级索引及其查询功能,请参阅此常见问题解答中的二级索引部分.

No. You can create a Global Secondary Index or Local Secondary Index on any top-level JSON element. For example, suppose you stored a JSON document that contained the following information about a person: First Name, Last Name, Zip Code, and a list of all of their friends. First Name, Last Name and Zip code would be top-level JSON elements. You could create an index to let you query based on First Name, Last Name, or Zip Code. The list of friends is not a top-level element, therefore you cannot index the list of friends. For more information on Global Secondary Indexing and its query capabilities, see the Secondary Indexes section in this FAQ.

问:可以索引哪些数据类型?

Q: What data types can be indexed?

所有标量数据类型(数字、字符串、二进制和布尔)都可以用于本地二级索引键的范围键元素.放,列表,并且地图类型不能被索引.

All scalar data types (Number, String, Binary, and Boolean) can be used for the range key element of the local secondary index key. Set, list, and map types cannot be indexed.

这篇关于DynamoDB 在地图或列表类型上创建索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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