使用带有嵌套 属性 的 ScanFilter 扫描 AWS DynamoDB

Scan AWS DynamoDB with ScanFilter with nested property

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

扫描过滤器是遗留的,您应该尝试使用 Filter Expression instead with an attribute_exists operator

尝试这样的操作(您也许可以删除 withNameMapwithValueMap 但尚未测试)

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

results = table.scan(scanSpec)