Sergio Rodriguez
Sergio Rodriguez

Reputation: 19

DynamoDB Scan ignoring uppercase or lowercase letters

My boss asked me to make a filter that does not recognize upper and lower case letters and I added the following code that makes the filter but recognizes the use of upper and lower case letters and does not find anything

    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()));

Upvotes: 1

Views: 1890

Answers (1)

DynamoDB it's case-sensitive right now, as you can see in this thread.

An alternative way to make this search would be to save another field with upper/lower case and change your search to this field.

Upvotes: 3

Related Questions