我一直在查看 AWS DynamoDB QueryRequest
的文档:http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/model/QueryRequest.html#getQueryFilter()
本文档表明 addQueryFilterEntry
是 QueryRequest
类中的有效函数。但是,我正在使用的 Dynamo DB V2 jar 中似乎缺少该符号。有人对我在返回搜索结果之前应该如何过滤搜索结果有任何建议吗?我不想循环遍历结果并删除应用程序层中的无效结果。
我的代码如下所示:
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();
我想补充一点: queryRequest = queryRequest.addQueryFilterEntry(key, 条件) 这不是编译报告错误查找符号。
最佳答案
确保升级到 newest AWS Java SDK (截至 2014 年 7 月 10 日,版本为 1.8.3),然后再解决 latest documentation site .
关于java - 如何使用 AWS DynamoDB QueryRequest 类中的 addQueryFilterEntry(String, Condition)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24654396/