我有一个包含列 Id 和 JSON 列的表。
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 示例 ..
最佳答案
取自 http://aws.amazon.com/dynamodb/faqs/
Q: Is querying JSON data in DynamoDB any different?
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: If I have nested JSON data in DynamoDB, can I retrieve only a specific element of that data?
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.
虽然我还没有设法做到,或者看到任何通过云形成完成的例子。
关于json - 如何在 C# 中为 Amazon Dynamo DB 中的 Json 属性(列值)创建全局二级索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34287356/