Reputation: 389
I have aws dynamo db table as follows.
Now I want to filter it as follows.
For that I used the following code and i get 0 results in my code.what's wrong with my code.how to fix it?
public ScanResult getAllMemos() {
ScanRequest scanRequest = new ScanRequest()
.withTableName(DB_NAME)
.withFilterExpression("contains(imgName,thumbnail)");
return util.getAmazonDynamoDBClient(getActivity()).scan(scanRequest);
}
Without filter expression I get all results.
Upvotes: 1
Views: 2416
Reputation: 8147
Like was discussed in the comments, you need to create an expression attribute value map with the value of the filter and use this.
Try something like this:
public ScanResult getAllMemos() {
Map<String, AttributeValue> expressionAttributeValues =
new HashMap<String, AttributeValue>();
expressionAttributeValues.put(":val", new AttributeValue().withS("thumbnail"));
ScanRequest scanRequest = new ScanRequest()
.withTableName(DB_NAME)
.withFilterExpression("contains(imgName,:val)")
.withExpressionAttributeValues(expressionAttributeValues);
return util.getAmazonDynamoDBClient(getActivity()).scan(scanRequest);
}
Upvotes: 2