Я пытаюсь обновить элемент, используя глобальный вторичный индекс. Ниже приведено определение моей таблицы. Я новичок в DynamoDb.DynamoDB - элемент обновления от GSI (PHP)
$response = $this->client->createTable([
'TableName' => 'rawproducts_products',
'AttributeDefinitions' => [
[
'AttributeName' => 'product_code',
'AttributeType' => 'N'
],
[
'AttributeName' => 'token',
'AttributeType' => 'S'
],
[
'AttributeName' => 'processed_at',
'AttributeType' => 'N'
],
[
'AttributeName' => 'created_at',
'AttributeType' => 'N'
]
],
'KeySchema' => [
[
'AttributeName' => 'product_code',
'KeyType' => 'HASH'
],
[
'AttributeName' => 'token',
'KeyType' => 'RANGE'
]
],
'LocalSecondaryIndexes' => [
[
'IndexName' => 'ProductCodeProcessedIndex',
'KeySchema' => [
['AttributeName' => 'product_code', 'KeyType' => 'HASH'],
['AttributeName' => 'processed_at', 'KeyType' => 'RANGE']
],
'Projection' => [
'ProjectionType' => 'KEYS_ONLY',
],
],
[
'IndexName' => 'ProductCodeCreatedIndex',
'KeySchema' => [
['AttributeName' => 'product_code', 'KeyType' => 'HASH'],
['AttributeName' => 'created_at', 'KeyType' => 'RANGE']
],
'Projection' => [
'ProjectionType' => 'KEYS_ONLY',
],
]
],
'GlobalSecondaryIndexes' => [
[
'IndexName' => 'TokenIndex',
'KeySchema' => [
[ 'AttributeName' => 'token', 'KeyType' => 'HASH' ]
],
'Projection' => [
'ProjectionType' => 'ALL'
],
'ProvisionedThroughput' => [
'ReadCapacityUnits' => 1, 'WriteCapacityUnits' => 1
]
]
],
'ProvisionedThroughput' => [
'ReadCapacityUnits' => 5,
'WriteCapacityUnits' => 6
]
]);
Когда я пытаюсь обновить атрибут «полной» с помощью запроса ниже:
$this->dynamoDb->updateItem([
'TableName' => $this->table,
'TableIndex' => 'TokenIndex',
'Key' => [
'token' => ['S' => (string)$this->token['S']]
],
'UpdateExpression' => 'set complete = :complete',
'ExpressionAttributeValues' => [
':complete' => ['N' => (string)1]
]
]);
Но я получаю следующее сообщение об ошибке:
"The provided key element does not match the schema"
Может кто-нибудь пожалуйста, посоветовать новичку , Большое спасибо.