如何在 C# 的 Amazon Dynamodb 中为 Json 属性(列值)创建全局二级索引?
How to create Global Secondary Index for Json Attributes(column values) in Amazon Dynamo DB in C#?
我有一个带有列 ID 和 JSON 列的 table。
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 的 table 中的列上创建 GSI。请提供一个 C#.Net 示例..
您可以在任何顶级 JSON 元素上创建 GSI 或 LSI。因此,您必须将 json 元素带到列级别,然后创建索引。
取自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.
尽管我还没有做到,也没有看到任何关于云形成的例子。
我有一个带有列 ID 和 JSON 列的 table。
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 的 table 中的列上创建 GSI。请提供一个 C#.Net 示例
您可以在任何顶级 JSON 元素上创建 GSI 或 LSI。因此,您必须将 json 元素带到列级别,然后创建索引。
取自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.
尽管我还没有做到,也没有看到任何关于云形成的例子。