1

我正在尝试扫描 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"
  }
}
4

1 回答 1

2

扫描过滤器是遗留的,您应该尝试使用过滤器表达式而不是使用attribute_exists 运算符

尝试这样的事情(您可能可以删除withNameMapandwithValueMap但尚未测试)

ScanSpec scanSpec = new ScanSpec().withFilterExpression("attribute_exists(name.firstName)").withNameMap(new NameMap()).withValueMap(new ValueMap());

results = table.scan(scanSpec)
于 2019-06-06T13:26:18.677 回答