-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Secondary Index is not working #270
Comments
Hello, maybe is an issue with your code. I can use global and local secondary index just fine. this is my YAML that works:
|
For me the index is working and present but always empty, result that the query returns nothing. TestTable:
Type: 'AWS::DynamoDB::Table'
Properties:
KeySchema:
-
AttributeName: id
KeyType: HASH
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
-
AttributeName: organisationID
AttributeType: S
-
AttributeName: createdAt
AttributeType: S
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: 'Test'
GlobalSecondaryIndexes:
-
IndexName: organisationID
KeySchema:
-
AttributeName: organisationID
KeyType: HASH
-
AttributeName: createdAt
KeyType: RANGE
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1 $ aws dynamodb describe-table --table-name Test --endpoint-url http://localhost:8888
{
"Table": {
"AttributeDefinitions": [
{
"AttributeName": "id",
"AttributeType": "S"
},
{
"AttributeName": "organisationID",
"AttributeType": "S"
},
{
"AttributeName": "createdAt",
"AttributeType": "S"
}
],
"TableName": "Test",
"KeySchema": [
{
"AttributeName": "id",
"KeyType": "HASH"
}
],
"TableStatus": "ACTIVE",
"CreationDateTime": "2021-11-13T10:39:00.009000+01:00",
"ProvisionedThroughput": {
"LastIncreaseDateTime": "1970-01-01T01:00:00+01:00",
"LastDecreaseDateTime": "1970-01-01T01:00:00+01:00",
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
},
"TableSizeBytes": 1256,
"ItemCount": 8,
"TableArn": "arn:aws:dynamodb:ddblocal:000000000000:table/Test",
"GlobalSecondaryIndexes": [
{
"IndexName": "organisationID",
"KeySchema": [
{
"AttributeName": "organisationID",
"KeyType": "HASH"
},
{
"AttributeName": "createdAt",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"IndexStatus": "ACTIVE",
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
},
"IndexSizeBytes": 1256,
"ItemCount": 0,
"IndexArn": "arn:aws:dynamodb:ddblocal:000000000000:table/Test/index/organisationID"
}
]
}
$ aws dynamodb scan --table-name Test --endpoint-url http://localhost:8888
{
"Items": [
{
"organisationID": {
"S": "org-test"
},
"_deleted": {
"BOOL": false
},
"name": {
"S": "Test"
},
"_rev": {
"S": "1-9479cd8b87afd68fd0194a209b364dd3"
},
"id": {
"S": "testID"
},
"status": {
"S": "drafting"
},
"updatedAt": {
"S": "2021-11-13T09:42:52.681Z"
}
},
...
]
}
aws dynamodb query --table-name Test --index-name organisationID --key-condition-expression 'organisationID = :org' --expression-attribute-values '{":org": { "S": "org-test" }}' --endpoint-url http://localhost:8888
{
"Items": [],
"Count": 0,
"ScannedCount": 0,
"ConsumedCapacity": null
} Any idea? I'm blocked in my local testing since I cannot replicate the remote behavior. |
My bad if you range key is empty it won't be indexed, in my sample the mistake is I wanted to index organisationID, updatedAt not createdAt |
I defined dynamodb table with global secondary index.
I requested query with GSI.
But an error occurred.
Is This plugin not support GSI?
request.vtl
serverless.yml
Error
The text was updated successfully, but these errors were encountered: