I'm using DynamoDB and also storing documents by passing JSON to it, all using the DynamoDBMapper class, in Java.
It's straightforward enough to put data in to the table. And also to query the table if you have the Hash or Range values available.
But I want to perform a scan (I presume) for a value with the JSON document. I've been hunting around for examples but I can't find any, or at least not when using the DynamoDBMapper way of doing things.
So would I be right in thinking this can be done? If so, does anyone have an example of doing this? Specifically, how do you specify the attribute in the document/JSON that you want to query on?
My table is set up with a Hash, Range and a "document" attribute containing the JSON that was passed to it. So if I wanted to check a "name" value within that "document", how do I specify that in a Condition?
Here's an example of a code snippet I have tried:
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
scanExpression
.addFilterCondition(
"document.name",
new Condition().withComparisonOperator(
ComparisonOperator.EQ)
.withAttributeValueList(
new AttributeValue()
.withS(existingWebsiteName)));
List<PublisherSite> scanResult = getMapper().scan(PublisherSite.class, scanExpression);
I have also tried specifiying the attributeName as just "name" too, but that doesn't work either. I get no results back.
PublisherSitecode, and amapper.save()call to make an MCVE?