Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamodb - Query by object property nested in array

I am having an issues with understanding does dynamoDb supports filtering by object properties nested in array. Example:

Consider that we have following table called "Street" where one item (row) in that table have following structure:

{
   name: "Street name",
   population: 20,
   houses: 5,
   people: [
      {
          first_name: "FName1",
          last_name: "LName1",
          ... other person's properties
      },
      {
          first_name: "FName2",
          last_name: "LName2",
          ... other person's properties
      },
      {
          first_name: "FName3",
          last_name: "LName3",
          ... other person's properties
      }

      ... etc
   ]
}

We can consider in this scenario that "name" is dynamodb prefix = which means that we can query based on the street name.

I am interested does dynamodb supports following logic: "Query based on street with specific name and filter it for the person with following specific name."

The result would be something like (whole point is to return only one person/object from array which match the filter)

{
   name: "Street nameX",
   population: 20,
   houses: 5,
   people: [
      {
          first_name: "FNameX",
          last_name: "LNameX",
          ... other person's properties
      }
   ]
}

Basically question is, can dynamoDb filter results after query based on the object properties nested in array.

Please make a note that I understand that I can achieve this with different table schema - but this example is used for simplicity and it is as it is - focusing question on 'does dynamoDB have support for something like this or not?'.

like image 294
cool Avatar asked Jun 29 '17 14:06

cool


People also ask

Can DynamoDB handle complex queries?

DynamoDB has many attractive features. For example, it can automatically scale to handle trillions of calls in a 24-hour period. It can be used as a key-value store or a document database, and it can handle complex access patterns much faster than a typical relational database.

Does DynamoDB support array?

A DynamoDB Set deserializes into an object with its array of items stored under the values property. If we want a Set to deserialize into an array, we'll need to add an unmarshalling step where we assign the values property instead of the deserialized set object itself.

Which is faster scan or Query in DynamoDB?

For faster response times, design your tables and indexes so that your applications can use Query instead of Scan . (For tables, you can also consider using the GetItem and BatchGetItem APIs.)

Can you Query by sort key only DynamoDB?

You can not query only using a Sort Key. You need to specify a partition key to perform query operations. Else, you need to create a global secondary index or perform a scan operation.


1 Answers

Looks like this is still not supported (at least back then at 2014).

Filtering / Querying by the Contents of a List in DynamoDB

like image 71
gustavoca Avatar answered Oct 02 '22 22:10

gustavoca