IsidroGH
IsidroGH

Reputation: 2037

DynamoDB: Contains all filter

I have a schema with a field called ids (list of numbers)

How can I create a QuerySpec to filter the items that contains all values of a specified list?

For example:

item 1: ids=[1,2,3]
item 2: ids=[1,3,5]

I need to retrieve only item 1 when I filter by [1,2]

I am using:

querySpec.withFilterExpression("contains(ids,:f1) and contains(ids,:f2)")

But I don't know if it is efficient or if there is a more convenient way to do it.

Upvotes: 1

Views: 426

Answers (1)

notionquest
notionquest

Reputation: 39226

The value cannot be SET, MAP or LIST. You have to use AND operator to achieve the result as mentioned in the OP.

CONTAINS is supported for lists: When evaluating "a CONTAINS b", "a" can be a list; however, "b" cannot be a set, a map, or a list.

Upvotes: 3

Related Questions