39

Is it possible to search on nested properties from AWS DynamoDB console? I am able to search on all top level properties, but search on any nested properties always results in empty result set.

For example for the document provided below I am able to scan and add filter on any top level field, like id, name, etc.

However I am unable to scan, and filter on device. I am trying the filter as device.name = 'Xaomi'

{ id: 'jhfdgu75457y8r', name: 'Parag', device: {name: 'Xaomi', country: 'China'} }

Please note that I am doing this from AWS console, and not any client library. Does AWS console allows filters on nested objects?

parags
  • 521
  • 1
  • 5
  • 10
  • 1
    I have the same problem. ---- Also, I validated in code (nodeJS) that it is possible to filter on a nested property. This can be done using **FilterExpressions**. – CSSian Jul 25 '16 at 20:59

4 Answers4

9

All data in DynamoDB is stored as either a string, binary or number.

When you use an SDK to access DynamoDB it will typically convert and unconvert these primatives into complex data types such as lists and maps.

The console works only on the primative data types. In this case your device attribute is treated as a string, and you cannot therefore filter by the device.name nested attribute.

You can however simply do a string filter. For example filter on the device attribute, using the contains operator and the value "name":"Xaomi"

F_SO_K
  • 13,640
  • 5
  • 54
  • 83
  • 25
    I'm running into a similar problem and your example of using only the column name in the first field and including the nested property and a substring in the matching field doesn't work. Even searching for the nested field name in the column doesn't show any results for me. – webbower Mar 08 '19 at 22:38
6

It isn't currently possible on the console.

I was also looking for a solution where I can find an item based on the value of a nested property.

But it is currently possible only via the SDK or CLI and not the console.

Confirmed by the AWS support team here - https://forums.aws.amazon.com/thread.jspa?messageID=931016

thedreamsaver
  • 1,294
  • 4
  • 16
  • 27
5

It is now possible in AWS console with the help of PartiQL editor. Open PartiQL editor and then you can write SQL like query:

SELECT * FROM YourTableName WHERE device.name = 'Xaomi'

It uses scan behind the scenes, just to be aware of that.

More on PartiQL: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.html

Ludevik
  • 6,954
  • 1
  • 41
  • 59
-4

In the Filter type "device" and not device.name and select "Contains" instead of "=" in the drop-down

Liat
  • 91
  • 4