14

I have a map within DDB, with various nested attributes. The map itself is called 'state', and has a nested property within called 'prop'.

I want to filter for all results that "contains" (within the dropdown) X within prop.

Unfortunately, I've tried various ways such as:

state.prop "CONTAINS" X
state.#prop "CONTAINS" X

I just can't seem to filter by anything other than the primary key. Any sort of nested filter, or a filter on any other column returns 0 results (when some definitely exist).

The majority of the examples are code or CLI based, not the DDB UI.

Please can someone provide me with an example of filtering through a map, on DDB, within AWS Console.

Many thanks.

  • 2
    Might not be possible https://stackoverflow.com/a/48792713/2684520 – webbower Mar 08 '19 at 22:32
  • if 'state' is the reserved word then I think #state.prop should work! – Abdelrahman Maharek Jan 08 '20 at 14:28
  • I really wanted to help you here (it's a highly voted question with no answer), but I just didn't understand you use case. Can you please show a concrete example of one item and how it's structured? In particular I didn't understand whether "prop" is a map, a list, or what, and whether each item has one "prop" or many cases of "prop" for different elements inside the same item. – Nadav Har'El Jun 22 '20 at 14:37

1 Answers1

1

I think the tidiest way to do this is to separate the value inside the map into a field on the root document (next to the partition and sort key) and then creating a Global Secondary Index (GSI) or a Local Secondary Index (LSI) depending on how you want to use it. You can then use the Query operation to search the index for the document and access the rest of the map properties in your code from there (In this instance you could name the field stateProof).

There is this thread which details the ability to use FilterExpression in Scan operations, however I think this is quite expensive if there's a-lot of documents in the DDB but it may well be much easier than adding new indexes and updating the existing DDB document format.

Rohan Hadnum
  • 233
  • 1
  • 2
  • 11