java - 如何使用 AWS DynamoDB QueryRequest 类中的 addQueryFilterEntry(String, Condition)?

标签 java amazon-web-services amazon-dynamodb

我一直在查看 AWS DynamoDB QueryRequest 的文档:http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/model/QueryRequest.html#getQueryFilter()

本文档表明 addQueryFilterEntryQueryRequest 类中的有效函数。但是,我正在使用的 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/

相关文章:

java - NodeJS 相当于 Java 中的字节

amazon-dynamodb - DynamoDB 查询性能 - 唯一分区键与唯一分区+排序键

node.js - 有没有办法从 node.js 同步调用 AWS Lambda?

mysql - CloudFormation 更改集显示替换,尽管没有更改

go - 具有许多属性的 UpdateItem

Java DynamoDB——仅在键不存在时插入(没有映射器)

java - Java、C++、Python 中的异常模型

java - 如何在java或groovy中解析Cucumber特征文件?

firefox - JRE 和 Java 插件的区别

amazon-web-services - 如何让未经身份验证的 Cognito 用户访问 AWS 上的 Dynamobdb?