amazon-web-services - 使用带有嵌套属性的 ScanFilter 扫描 AWS DynamoDB
问题描述
我正在尝试扫描 dynamodb,并且我的扫描在根属性上运行良好,但不适用于嵌套属性。我的代码库是:
String workingProperty = "name"
String notWorkingProperty1 = "name.firstName"
String notWorkingProperty2 = "#name.firstName"
String notWorkingProperty3 = "#name.#firstName"
private Table table;
public List<Item> getAllFilteredItems() {
ScanFilter scanFilter = new ScanFilter(propertyToLookFor).exists();
StreamSupport.stream(table.scan(scanFilter).spliterator(), false)
.collect(Collectors.toList());
}
我的 JSON 是:
{
"name": {
"firstName": "Manish"
}
}
解决方案
扫描过滤器是遗留的,您应该尝试使用过滤器表达式而不是使用attribute_exists 运算符。
尝试这样的事情(您可能可以删除withNameMap
andwithValueMap
但尚未测试)
ScanSpec scanSpec = new ScanSpec().withFilterExpression("attribute_exists(name.firstName)").withNameMap(new NameMap()).withValueMap(new ValueMap());
results = table.scan(scanSpec)
推荐阅读
- javascript - 错误消息后更新状态 - Firebase - React Native
- r - 在闪亮中,如何在文本输入中插入数学符号,以便我的 r 代码执行方程式?
- c++ - 从 Visual Studio 中间窗口调用方法 nlohmann::json::dump
- c# - MVVM Window 的新实例打破了绑定
- r - Runnin R 脚本的 VBA Shell
- javascript - 如何在我的命令中编写子命令?
- python - PyPI 如何决定包的最新版本是什么?
- python - 无服务器部署上的“资源类型无法更改”
- javascript - 加载 Handlebars 模板后按类名获取元素?
- php - Laravel 将业务逻辑放在 Model 中是否正确?