问题描述
我有一张桌子,并设置了一个GSI来进行查询。我为其设置条件的属性的类型为number。我像这样设置比较的属性值:AttributeValue value = new AttributeValue(); value.setN(String.valueOf(3));
i have a table and have set up a GSI to do a query. the attribute that i am setting the condition for is of type number. i set the attribute value for the comparison like this: AttributeValue value = new AttributeValue(); value.setN(String.valueOf(3));
我成功地执行了一个将CompareOperator设置为EQ的查询。给出了正确的结果,但其他选项(NE | LE | LT | GE | GT |等)均无效。它们都抛出ValidationException-不支持查询键条件(服务:AmazonDynamoDB;状态代码:400; ...
i succeed in doing a query where the ComparisonOperator is set to EQ. the correct result is given but none of the other options ( NE | LE | LT | GE | GT | etc) work. they all throw a ValidationException - Query key condition not supported (Service: AmazonDynamoDB; Status Code: 400;...
我在做什么错了?
非常感谢
推荐答案
使用分区键属性查询GSI时,只有等号运算符
When you query the GSI with partition key attribute, only equality operator is allowed for the partition key. If you don't know the value of partition key, you need to use scan api.
查询api允许其他条件运算符提供排序键,如果您不知道分区键的值,则需要使用扫描API。属性。但是,您只能对分区键使用相等运算符。否则,不能使用查询api。
Query api allows other conditional operators for sort key attribute. However, you can use only equality operator for partition key. Otherwise, you can't use query api.
Filterexpression允许在使用它时使用所有条件运算符具有非关键属性。
Filterexpression allows all kind of conditional operators when you use it with non-key attributes.
这篇关于DynamoDb“不支持查询关键条件”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!