【问题标题】:DynamoDB Scan ignoring uppercase or lowercase lettersDynamoDB 扫描忽略大写或小写字母
【发布时间】:2021-06-25 21:22:55
【问题描述】:

我的老板让我做一个不能识别大小写字母的过滤器,我添加了以下代码来制作过滤器但识别大小写字母的使用并且没有找到任何东西

    DynamoDBMapper mapper = new DynamoDBMapper(amazonDynamoDB);
    DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
    Map<String, AttributeValue> eav = new HashMap<String, AttributeValue>();
    Map<String, String> ean = new HashMap<String, String>();

    StringJoiner where = new StringJoiner(" and ");
    if (status != null) {
        eav.put(":status", new AttributeValue().withS(status));
        where.add("#status = :status");
        ean.put("#status", "status");
        scanExpression.withExpressionAttributeNames(ean);
    }
   if (where.length() > 0) {
                            scanExpression.withFilterExpression(where.toString()).withExpressionAttributeValues(eav).withConsistentRead(false);
        }

        // Scan to the end of the page after the requested page
        int scanTo = (int) (pageable.getOffset() + (2 * pageable.getPageSize()));

【问题讨论】:

    标签: amazon-dynamodb case dynamodb-queries ignore-case


    【解决方案1】:

    DynamoDB 现在区分大小写,正如您在 thread 中看到的那样。

    进行此搜索的另一种方法是使用大写/小写保存另一个字段并将您的搜索更改为该字段。

    【讨论】:

    • 对。如果您听 DynamoDB 开发人员描述此产品,您会一次又一次地获得一个见解,即在使用 DynamoDB 时,您需要根据您期望获得的查询类型仔细规划您的数据模型。您经常添加额外的属性甚至二级索引,特别是为特定类型的查询提供服务 - 在您的情况下,您可以添加属性的小写版本作为第二个属性,以用于不区分大小写的查询。跨度>
    猜你喜欢
    • 2016-06-06
    • 2021-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-05
    • 2016-02-16
    • 1970-01-01
    相关资源
    最近更新 更多