Amazon dynamodb 查询字段未定义的项目的全局辅助索引
我有一个带有散列键Amazon dynamodb 查询字段未定义的项目的全局辅助索引,amazon-dynamodb,Amazon Dynamodb,我有一个带有散列键s1和范围键s2的表test1,该表有一个带有散列键s3和范围键s4的全局二级索引gsi1 $ aws dynamodb describe-table \ --table-name test1 { "Table": { "AttributeDefinitions": [ { "AttributeName": "s1&q
s1
和范围键s2
的表test1
,该表有一个带有散列键s3
和范围键s4
的全局二级索引gsi1
$ aws dynamodb describe-table \
--table-name test1
{
"Table": {
"AttributeDefinitions": [
{
"AttributeName": "s1",
"AttributeType": "S"
},
{
"AttributeName": "s2",
"AttributeType": "S"
},
{
"AttributeName": "s3",
"AttributeType": "S"
},
{
"AttributeName": "s4",
"AttributeType": "S"
}
],
"TableName": "test1",
"KeySchema": [
{
"AttributeName": "s1",
"KeyType": "HASH"
},
{
"AttributeName": "s2",
"KeyType": "RANGE"
}
],
"TableStatus": "ACTIVE",
"CreationDateTime": "2020-11-19T23:36:40.457000+08:00",
"ProvisionedThroughput": {
"LastIncreaseDateTime": "1970-01-01T08:00:00+08:00",
"LastDecreaseDateTime": "1970-01-01T08:00:00+08:00",
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 3,
"WriteCapacityUnits": 3
},
"TableSizeBytes": 50,
"ItemCount": 3,
"TableArn": "arn:aws:dynamodb:ap-southeast-1:000000000000:table/test1",
"GlobalSecondaryIndexes": [
{
"IndexName": "gsi1",
"KeySchema": [
{
"AttributeName": "s3",
"KeyType": "HASH"
},
{
"AttributeName": "s4",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"IndexStatus": "ACTIVE",
"ProvisionedThroughput": {
"ReadCapacityUnits": 3,
"WriteCapacityUnits": 3
},
"IndexSizeBytes": 37,
"ItemCount": 1,
"IndexArn": "arn:aws:dynamodb:ddblocal:000000000000:table/test1/index/gsi1"
}
]
}
}
我有这个东西。请注意,s4
不存在
$ aws dynamodb get-item \
--table-name test1 \
--key '{"s1":{"S":"chen"}, "s2":{"S":"yan"}}'
{
"Item": {
"s3": {
"S": "fei"
},
"s1": {
"S": "chen"
},
"s2": {
"S": "yan"
}
}
}
我试图通过此查询查询该项的索引gsi1
,但出现以下错误
$ aws dynamodb query \
--table-name test1 \
--index-name gsi1 \
--expression-attribute-values '{
":s3": {"S": "fei"},
":s4": {"NULL": true}
}' \
--key-condition-expression 's3 = :s3 AND s4 = :s4'
An error occurred (ValidationException) when calling the Query operation: One or more parameter values were invalid: Condition parameter type does not match schema type
我也尝试了这个查询,但没有得到任何项目
$ aws dynamodb query \
--table-name test1 \
--index-name gsi1 \
--expression-attribute-values '{
":s3": {"S": "fei"}
}' \
--key-condition-expression 's3 = :s3'
{
"Items": [],
"Count": 0,
"ScannedCount": 0,
"ConsumedCapacity": null
}
知道如何查询该项目的索引吗?你不能
如果该项没有GSI键所需的属性,则不会将其添加到GSI
这被称为