我有以下解析程序,可以通过IN
运算符组合的ID列表来获取项目。
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
## Provide a query expression. **
"expression": "studentId = :id",
"expressionValues" : {
":id" : { "S": "$ctx.args.studentId" }
}
},
"filter": {
"expression": "topicId IN :ids",
"expressionValues" : {
":ids" : { "NS" : $ctx.args.topicIds }
}
},
"index": "studentId-index",
}
收到以下错误:
{
"data": {
"listStudentBookmarkedTopics": null
},
"errors": [
{
"path": [
"listStudentBookmarkedTopics"
],
"data": null,
"errorType": "DynamoDB:AmazonDynamoDBException",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3
}
],
"message": "Invalid FilterExpression: Syntax error; token: \":ids\", near:
\"IN :ids\" (Service: AmazonDynamoDBv2; Status Code: 400; Error Code:
ValidationException; Request ID:
R49QUD5LDF7KS83ABNTPLP10RBVV4KQNSO5AEMVJF66Q9ASUAAJG)"
}
]
}
答案 0 :(得分:1)
您可以尝试将过滤器表达式更改为以下内容吗?
"filter": {
"expression": "contains(:ids, topicId)",
"expressionValues" : {
":ids" : { "NS" : $util.toJson($ctx.args.topicIds) }
}
}
这会添加对 $ util.toJson 的调用,并使用包含 DynamoDB过滤器表达式。