I need to scan the tables by subfield JSON, which is located in one column. Unfortunately I can't find anywhere example in Java and do not know if it is possible.
This is my data and this json represents object - one row in dynamodb. The json represents 3 java classes: - main class which contains the class city and some string record - city contains a class road
Is it possible to scan the database and find the records with mainName = "xyz" and having a city record called "Rockingham"
{
"Id": "9",
"mainName": "xyz",
"floatVariable": 228.3,
"city": [
{
"name": "Rockingham",
"road": [
{
"roadName": "Traci",
"roadLength": 118
},
{
"roadName": "Watkins",
"roadLength": 30
}
]
}
],
"house": { "huseName": "Wendy Carson" } }
I have some like this and this work but this is not enough to query correct data. Table table = dynamoDB.getTable(tableName);
Map<String, Object> expressionAttributeValues = new HashMap<String, Object>();
expressionAttributeValues.put(":pr", 300);
ItemCollection<ScanOutcome> items = table.scan(
"floatVariable < :pr", //FilterExpression
"Id, mainName, floatVariable, city" , //ProjectionExpression
null, //ExpressionAttributeNames - not used in this example
expressionAttributeValues);
System.out.println("Scan of " + tableName + " for items with a price less than 300.");
Iterator<Item> iterator = items.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next().toJSONPretty());
}
I saw an example in php something like this but unfortunately it does not work in Java.
ItemCollection<ScanOutcome> items = table.scan(
" cites.name = :dupa ", //FilterExpression
"Id, mainName, floatVariable, city", //ProjectionExpression
null, //ExpressionAttributeNames - not used in this example
expressionAttributeValues);