Reputation: 15
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.
Upvotes: 1
Views: 1423
Reputation: 10052
Make sure you upgrade to the newest AWS Java SDK (as of 10-Jul-2014 it's 1.8.3) before tackling the latest documentation site.
Upvotes: 2
Reputation: 3614
you need to give more details.
make sure you are importing the latest QueryRequest
import com.amazonaws.services.dynamodbv2.model.QueryRequest;
Upvotes: 0