DynamoDB Nested Query Support

Amazon DynamoDB scan operation allows you to query nested attributes like Array or Object ? For example,

 { Id: 206, Title: "20-Bicycle 206", Description: "206 description", RelatedItems: [ 341, 472, 649 ], Pictures: { FrontView: "123", RearView: "456", SideView: "789" } } 

Can I request attributes of RelatedItems[2] or Pictures.RearView ?

+8
amazon-dynamodb
source share
2 answers

Yes, you can use a filter expression that is similar to a condition expression. The section on functions that you can use in these types of expressions mentions the following:

"For a nested attribute, you must specify its full path; for more information, see Document Paths .

The Document Paths reference provides examples of how to reference nested attributes in DynamoDB Data Types , such as List (that you are calling an array) and Map (that you are calling the object). Check out this link for examples on how to do this:

  • MyList [0]
  • AnotherList [12]
  • ThisList [5] [11]
  • MyMap.nestedField
  • MyMap.nestedField.deeplyNestedField
+12
source share

Note that in DyanomoDB, query and scan completely different ( scan is a much more expensive operation). That way, while you can filter on both, as pointed out by @coffeeplease; you can only query / index:

The key scheme for the index. Each attribute in the index key schema must be a top-level attribute of type String, Number, or Binary. Other data types, including documents and sets, are not allowed ( ref ).

+1
source share

All Articles