I've been looking at the documentation for AWS DynamoDB QueryRequest
at: http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/model/QueryRequest.html#getQueryFilter()
This documentation suggests that addQueryFilterEntry
is a valid function inside the QueryRequest
class. However, the symbol seems to be missing in the Dynamo DB V2 jars that I am using. Does anyone have any suggestions as to what I should do to filter the search results before returning them? I'd rather not loop through the results and remove the invalid results in the application layer.
My code looks something like below:
import com.amazonaws.services.dynamodbv2.model.QueryRequest;
String hashKey = Utilities.normalize(user_id);
Condition hashKeyCondition = new Condition()
.withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue().withS(hashKey));
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("UserId", hashKeyCondition);
// Gets count of all matching results.
QueryRequest queryRequest = new QueryRequest().withTableName(storiesTable)
.withKeyConditions(keyConditions)
.withSelect(Select.COUNT)
.withConsistentRead(true);
QueryResult result = dynamoDB.query(queryRequest);
int countResults = result.getCount();
I wanted to add: queryRequest = queryRequest.addQueryFilterEntry(key, Condition) and this is not compiling reporting error finding the symbol.