4

I have a JSON document stored in an attribute called doc that looks something like this:

{
    doc:  
        {
            "foo": 
                {
                     "bar": "baz"
                }
         }
}

I'd like to be able to do a table scan and filter/search on data.foo.bar == "baz". I'm using the Java SDK and have tried the following code but it doesn't seem to work for a sub-map of a document:

String filterExpression = "#d.#f.#b = :val";
Map<String, String> nameMap = new HashMap();
nameMap.put("#d", "doc");
nameMap.put("#f", "foo");
nameMap.put("#b", "bar");
Map valueMap = new HashMap();
valueMap.put(":val", "baz");
ItemCollection<ScanOutcome> items = table.scan(
    new ScanSpec()
        .withFilterExpression(filterExpression)
        .withNameMap(nameMap)
        .withValueMap(valueMap));

EDIT - I have found that this works:

String filterExpression = "#d.foo.bar = :val";

Where I only have a single ExpressionAttributeNames for the first attribute it works. Any thoughts why it doesn't work with 3 ExpressionAttributeNames? What if by some chance I needed 3, i.e. they were reserved words?

Any help or suggestions greatly appreciated. Thanks.

fogwolf
  • 931
  • 7
  • 26

0 Answers0