I have a List with ID's of type String. I want to scan DynamoDB and get a result list with items that do NOT have these ID's. But I can not figure out how to type the filter expression. ReviewId is the primary partition key of type String.
Map<String, AttributeValue> eav = new HashMap<>();
eav.put(":idFilter", new AttributeValue().withSS(idFilter));
DynamoDBScanExpression scanExp = new DynamoDBScanExpression()
.withFilterExpression("ReviewId <> (:idFilter)")
.withExpressionAttributeValues(eav);
The above filter expression is valid but it still always returns items with id's in the list.
I have also tried to include the word in
before and after the <>
operator.
You can change the filter expression as below and populate the ExpressionAttributeValues
with values for keys :reviewId1, :reviewId2, :reviewId3
.
FilterExpression: "NOT ReviewId in (:reviewId1, :reviewId2, :reviewId3)"
Note:-
Unfortunately, you can't keep the idFilter
as SET or LIST to compare with String attribute of DynamoDB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With