Amazon dynamodb 执行Dynomodb查询时出错
以下是我的配置:Amazon dynamodb 执行Dynomodb查询时出错,amazon-dynamodb,Amazon Dynamodb,以下是我的配置: Table Name: MY_TABLE Primary partition key method (String) Primary sort key path (String) 我想再查询两个字段: 1. method (Primary partition key): GET 2. path (Primary sort key): /greet/v1/hello 我使用了“#pathKey”,因为“path”是一个保留关键字。(与#methodKey类似) 但在
Table Name: MY_TABLE
Primary partition key method (String)
Primary sort key path (String)
我想再查询两个字段:
1. method (Primary partition key): GET
2. path (Primary sort key): /greet/v1/hello
我使用了“#pathKey”,因为“path”是一个保留关键字。(与#methodKey类似)
但在这样做时,我得到了以下错误:
An error occurred (ValidationException) when calling the Query operation: Invalid KeyConditionExpression: An expression attribute name used in the document path is not defined; attribute name: #pathKey
请注意,我不想使用外部JSON文件传递参数,需要在命令行上运行。您应该在同一CLI参数下提供所有表达式属性名称(对于值也是如此) 发生的情况是,
--表达式属性名称“{”#methodKey”:“method”}”
覆盖了前面的一个。因此,错误是关于缺少#路径键
它应该以这种方式为您工作:
aws dynamodb query --table-name MY_TABLE \
--key-condition-expression '#pathKey=:path1 AND #methodKey=:method1' \
--expression-attribute-names '{"#pathKey":"path", "#methodKey":"method"}' \
--expression-attribute-values '{":path1":{"S":"/greet/v1/hello"}, ":method1":{"S":"GET"}}'
我尝试了您的解决方案,但现在出现了以下错误:调用查询操作时发生错误(ValidationException):无效的KeyConditionExpression:未定义文档路径中使用的表达式属性名称;属性名称:#pathKeyit与您在问题中提到的相同是的,我问过这个问题
aws dynamodb query --table-name MY_TABLE \
--key-condition-expression '#pathKey=:path1 AND #methodKey=:method1' \
--expression-attribute-names '{"#pathKey":"path", "#methodKey":"method"}' \
--expression-attribute-values '{":path1":{"S":"/greet/v1/hello"}, ":method1":{"S":"GET"}}'