Prasanna Sundar
Prasanna Sundar

Reputation: 1660

How to query and filter on a List of objects type data stored on dynamodb?

I have a list named "A" which stores a list of objects. Each object will be something like this,

"A" : [
    {
        "B" : "aaaaa",
        "C" : "sssss"
    },
    {
        "B" : "asasa",
        "C" : "sasas"
    }
]

How would I query and filter these objects held by A? I have tried the following KeyCondition Expressions,

" A[*].B = 'aaaaaa' "

" A.B = 'aaaaaa' "

But none of it does what I like to do.

EDIT 1:

Using "aws-java-sdk-dynamodb" v1.11.31

Query Spec is built as below,

QuerySpec query = new QuerySpec().withHashKey("user_name", "disney")
                                 .withFilterExpression("A[*].B = :value")
                                 .withValueMap(new ValueMap()
                                 .withString(":value","aaaaa"));
ItemCollection<QueryOutcome> = table.query(query);

Upvotes: 3

Views: 788

Answers (1)

Prasanna Sundar
Prasanna Sundar

Reputation: 1660

I guess, there is no way to accomplish what I was trying to do. I ended up writing loop which generated the filter expressions I needed and I was querying multiple times to accomplish this.

Upvotes: 1

Related Questions