簡體   English   中英

如何使用 OR 條件掃描 AWS 控制台中的發電機表?

[英]How to scan dynamo table in AWS console with OR condition?

最近,我開始使用dynamo table並且來自SQL背景,我對它的工作方式有點困惑。

我想知道是否可以使用OR條件scan the table 我所看到的只是AND條件,如下所示。

在此處輸入圖片說明

即假設我的列名是id並且我想獲得多個ids結果,那么我該怎么做呢? 我很確定必須有某種方式,但我不知道。

我們可以通過代碼在過濾器表達式中實現 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM