我有一个带有字母数字字符串作为哈希键的DynamoDB表(例如“d4ed6962-3ec2-4312-a480-96ecbb48c9da”).我需要根据表中的另一个字段查询表,因此我需要我的查询来选择所有键,例如我的字段x在dat x和date y之间.
我知道我需要哈希键上的条件和范围键上的另一个条件,但是我很难编写一个不将我的查询绑定到特定ID的哈希键条件.
我以为我可以根据ID为NOT_NULL的冗余条件逃脱,但是当我使用它时,我得到错误:
Query key condition not supported
以下是我正在使用的条件,任何想法如何实现这一目标?
Condition hashKeyCondition = new Condition()
.withComparisonOperator(ComparisonOperator.NOT_NULL.toString());
Condition rangeCondition = new Condition()
.withComparisonOperator(ComparisonOperator.BETWEEN.toString())
.withAttributeValueList(new AttributeValue().withS(dateFormatter.print(lastScanTime())),
new AttributeValue().withS(dateFormatter.print(currentScanTime)));
Map keyConditions = new HashMap();
keyConditions.put("userId", hashKeyCondition);
keyConditions.put("lastAccesTime", rangeCondition);
在此先感谢大家的帮助.