amazon-dynamodb - AWS Appsync - 查询 DynamoDB 的空索引
问题描述
我想获取一个附加到Query
AppSync 模式的 DynamoDB 表,以便仅获取具有全局二级索引 (GSI) 的属性的 空值或空值。
我尝试了以下但无法得到结果:
抛出 [KeyConditionExpression: OR] 中使用的无效运算符:
"operation" : "Query",
"index" : "myAttrIndex",
"query" : {
"expression" : "attribute_not_exists(myAttr) or myAttr = :null",
"expressionValues" : {
":null" : { "NULL" : null }
}
}
抛出 [KeyConditionExpression 中使用的无效运算符:attribute_not_exists]:
"operation" : "Query",
"index" : "myAttrIndex",
"query" : {
"expression" : "myAttr = :null",
"expressionValues" : {
":null" : { "NULL" : null }
}
}
抛出 [一个或多个参数值无效:条件参数类型与架构类型不匹配]:
"operation" : "Query",
"index" : "myAttrIndex",
"query" : {
"expression" : "myAttr = :null",
"expressionValues" : {
":null" : { "NULL" : null }
}
}
如何编写过滤掉字符串属性的非空值的查询文档?
解决方案
默认情况下,全局二级索引是稀疏的。
对于表中的任何项目,如果项目中存在索引键值,DynamoDB 只会将相应的条目写入全局二级索引。对于全局二级索引,这是索引分区键及其排序键(如果存在)。如果索引键值没有出现在每个表项中,则称该索引是稀疏的。
如果您需要myAttr
将属性空值包含在 GSI 表中,您可以设置一个虚拟值(例如“NULL”),然后查询该值。请注意,所有表格项目现在都将包含在 GSI 表格中,这将增加您的成本。
推荐阅读
- java - Storm Stream API 中 Executor 和 Bolt 的关系
- python - 根据条件填充 NumPy 数组
- xamarin - ZXing ZXingScannerPage:手电筒/手电筒不工作(Xamarin.Forms)
- assembly - Writeint 不显示 EAX 寄存器中的值
- python - 如何获得y轴的等距对数缩放
- django - Django:错误实现 ComputedTextField(无法在没有主键的情况下强制更新 save())
- powershell - 组合框选择到变量
- docker - Docker - 无法 ping 后端
- python - 无法在 Tensorflow 中运行 tf.math.reduce_std 和 tf.math.reduce_variance?(错误:输入必须是实数或复数)
- twitter-bootstrap - 如何在 Bootstrap-5 中创建响应式视频