[英]How to scan dynamo table in AWS console with OR condition?
有 OR 條件運算符,就像您想要的 Query 而不是 Scan。
我們可以通過代碼在過濾器表達式中實現 Scan with OR 。
例子:
ScanResult result = null;
ScanRequest req = new ScanRequest();
Map<String, AttributeValue> expressionAttributeValues = new HashMap<String, AttributeValue>();
expressionAttributeValues.put(":dateStr", new AttributeValue().withS(date));
expressionAttributeValues.put(":subDate1", new AttributeValue().withS(subDate1));
req.setTableName(emailEventNotifsTableName);
req.withFilterExpression("(begins_with(LastUpdated, :dateStr) or begins_with(LastUpdated, :subDate1))")
.withExpressionAttributeValues(expressionAttributeValues);
int count = 0;
dailyStatsTotalRows = new ArrayList<Map<String, AttributeValue>>();
do {
// ctx.getLogger().log("(getEmailEventNotifsTableStats)Iterating no:" + (++count));
if (result != null) {
req.setExclusiveStartKey(result.getLastEvaluatedKey());
}
result = getAmazonDynamoDBClient().scan(req);
List<Map<String, AttributeValue>> rows = result.getItems();
for (Map<String, AttributeValue> row : rows) {
String lastUpdated = row.get("LastUpdated").getS();
...
}
} while (result.getLastEvaluatedKey() != null);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.