ItemCollection<QueryOutcome> items = null;
QuerySpec querySpec = new QuerySpec();
ValueMap valueMap = new ValueMap();
valueMap.withString(":autoIdVal", autoID);
valueMap.withString(":docTypeVal", docType);
valueMap.withString(":username", username);
valueMap.withString(":comment", comment);
Map<String, String> nameMap = new LinkedHashMap<>();
nameMap.put("#comment", "comment");
querySpec.withKeyConditionExpression("autoID = :autoIdVal").withFilterExpression("(docType = :docTypeVal AND username = :username) OR (#comment = :comment)")
.withValueMap(valueMap)
.withNameMap(nameMap);
items = table.query(querySpec);
Iterator<Item> iterator = items.iterator();
Item itemData = null;
while (iterator.hasNext()) {
itemData = iterator.next();
System.out.println("Json data ====================>" + itemData.toJSONPretty());
}
1) withKeyConditionExpression - For hash key and range key expressions
2) withFilterExpression - For all other attributes (i.e. other than key attributes)
aws dynamodb query with or condition
猜你喜欢
转载自blog.csdn.net/zhouyan8603/article/details/82907903
今日推荐
周排行