我有三个条件条件。我在dynamo db表中指定了索引。我需要一种方法来指定所有三个索引,如果这是一个好的做法或任何其他基于表达式查询的方式。
此外,我想知道表达式是否有效。
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
## Also not sure about the query expression. Is it valid ?
"expression": "studentId = :studentId and (chapterId = :chapterId isUserAudio = :isUserAudio)",
"expressionValues" : {
":studentId" : {
"S" : "${ctx.args.studentId}"
},
":chapterId": {
"S": "${ctx.args.chapterId}"
},
":isUserAudio": {
"BOOL": "${ctx.args.isUserAudio}"
}
}
},
"index": "" # can multiple indexes be specified here
}
答案 0 :(得分:1)
studentId = :studentId AND chapterId = :chapterId AND isUserAudio = :isUserAudio
答案 1 :(得分:1)
我相信您应该能够使用查询表达式和过滤器表达式的组合来实现您的目标。尝试将解析器更改为:
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
"expression": "studentId = :studentId",
"expressionValues" : {
":studentId" : {
"S" : "${ctx.args.studentId}"
}
}
},
"filter" : {
"expression": "chapterId = :chapterId AND isUserAudio = :isUserAudio",
"expressionValues" : {
":chapterId": {
"S": "${ctx.args.chapterId}"
},
":isUserAudio": {
"BOOL": "${ctx.args.isUserAudio}"
}
}
},
"index": "the-index-with-studentId-as-a-hashkey"
}
这将首先查询索引,然后使用索引的结果将过滤器应用于值。如果有效,请告诉我!
希望这有帮助