1

I have this scan expression which returns a list of blogs matching the query (By title). How can I scan multiple attributes in the table and also ignore the case of the query?

      public List<BlogDetailsEntity> searchBlogs(String query) {
    try {
      DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
      scanExpression.addFilterCondition("title", new Condition()
              .withComparisonOperator(ComparisonOperator.CONTAINS)
              .withAttributeValueList(new AttributeValue().withS(query)));
     scanExpression.addFilterCondition("shortDescription", new Condition()
              .withComparisonOperator(ComparisonOperator.CONTAINS)
              .withAttributeValueList(new AttributeValue().withS(query)));
      return dynamoDBMapper.scan(BlogDetailsEntity.class, scanExpression);
    } catch (Exception ex) {
      log.error("failed to get blogs > " + query);
    }
    return null;
  }
Clancinio
  • 734
  • 6
  • 21
  • 40
  • If you need general purpose search, you should consider an actual search engine, such as Elasticsearch. – jarmod Mar 14 '21 at 22:54

1 Answers1

0
  • Multiple attributes: you can have multiple filter conditions on a single scan.
  • Ignore casing: As of 2017, this was not available. The suggested work-around is to add a field to the objects with the value in lowercase and filter on that.
sigma1510
  • 1,165
  • 1
  • 11
  • 26