问题描述
我有一个包含列Id和JSON列的表。
I have a table with column Id and JSON column.
Id | JSON
----------------------------------------------------------------
101 | {"person_id":456,"f_name":"t", "l_name":"Jack"}
|
102 | {"person_id":123,"f_name":"M", "l_name":"Ron"}
|
103 | {"person_id":789,"f_name":"A", "l_name":"Tom"}
我能够在列Id上创建GSI(全局二级索引),但我想知道如何在 person_id
和 f_name上创建GSI
。是否可以为json属性创建GSI?在观察时,我能够在Dynamo DB表中的列上创建GSI。请提供C#.Net示例 ..
I am able to create GSI(Global Secondary Index) on column Id , but I would like to know how to create GSI on person_id
and f_name
. Is it possible to create GSI for json attributes? As upon observation, I was able to create GSI on columns in tables of Dynamo DB..Please provide a C#.Net example..
推荐答案
取自
否。您可以在任何顶级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.
问:如果我已嵌套DynamoDB中的JSON数据,我只能检索该数据的
特定元素吗?
Q: If I have nested JSON data in DynamoDB, can I retrieve only a specific element of that data?
是。使用GetItem,BatchGetItem,Query或Scan API时,
可以定义ProjectionExpression以确定应从表中检索哪些属性
。这些属性可以包括标量,
集或JSON文档的元素。
Yes. When using the GetItem, BatchGetItem, Query, or Scan APIs, you can define a ProjectionExpression to determine which attributes should be retrieved from the table. Those attributes can include scalars, sets, or elements of a JSON document.
虽然我没有设法做它,或看到任何云形成的例子。
Although I haven't managed to do it, or seen any examples of it being done with cloud formation.
这篇关于如何在C#中的Amazon Dynamo DB中为Json属性(列值)创建全局二级索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!