2016-05-30 21 views
1

私はC.アマゾンDynamoDBのにValidationException

{ "TableName": "table4", "KeyConditionExpression": "#yr = :yyyy and ts between :letter1 and :letter2", "ExpressionAttributeNames": { "#yr": "userid" }, "ExpressionAttributeValues": { ":yyyy": "abc", ":letter1": 1, ":letter2": 2 } } 

にAWS-ダイナモライブラリを使用してDynamoDBのクエリのparamを、次の実行ですが、私はエラー

"__type":"com.amazon.coral.validate#ValidationException","message":"1 validation error detected: Value null at 'hashKeyValue' failed to satisfy constraint: Member must not be null" 

を得たが、これは私のテーブル構造である

table4 
{ 
    "Table": { 
     "TableSizeBytes": 66, 
     "KeySchema": [ 
      { 
       "AttributeName": "userid", 
       "KeyType": "HASH" 
      }, 
      { 
       "AttributeName": "ts", 
       "KeyType": "RANGE" 
      } 
     ], 
     "CreationDateTime": 1464617195.039, 
     "ItemCount": 3, 
     "AttributeDefinitions": [ 
      { 
       "AttributeName": "ts", 
       "AttributeType": "N" 
      }, 
      { 
       "AttributeName": "userid", 
       "AttributeType": "S" 
      } 
     ], 
     "ProvisionedThroughput": { 
      "ReadCapacityUnits": 1, 
      "WriteCapacityUnits": 1, 
      "LastDecreaseDateTime": 1464683346.007, 
      "NumberOfDecreasesToday": 1 
     }, 
     "TableStatus": "ACTIVE", 
     "TableName": "table4", 
     "TableArn": "arn:aws:dynamodb:us-east-1:456456456:table/table4" 
    } 
} 
+1

表のパーティション・キーとソートキーは何? KeyConditionExpressionにパーティションキーフィールドを含めましたか? – notionquest

+0

パーティションキー=ユーザーID、sortkey = ts –

答えて

0

keyconditionexpressionにはパーティションキーが必須です。パーティションキーを含めて試してみてください。 dynamodbを照会するときは、パーティションキーが必要です。ダイナモブロックをスキャンするときは、パーティションキーはオプションです。これは、dynamodbでの照会とスキャンの主な違いです。

+0

私は既に私のkeyconditionexpressionにパーティションキー(userid)を追加しました。 –

+0

describe tableコマンドを実行して、ここにテーブル構造を貼り付けてください。 – notionquest

+0

私の質問にテーブル構造を追加しました –

0

ここでは、動作中のクエリとテーブル構造があります。

{ TableName: 'table4', 
KeyConditionExpression: '#userid = :userid AND #ts between :ts1 AND :ts2', 
ExpressionAttributeNames: { '#userid': 'userid', '#ts': 'ts' }, 
ExpressionAttributeValues: { ':userid': 'user1', ':ts1': 1, ':ts2': 2 } } 

クエリ出力: -

{"userid":{"S":"user1"},"ts":{"N":"1"}} 

テーブルの構造: -

{"Table":{"AttributeDefinitions": 
     [{"AttributeName":"userid","AttributeType":"S"}, 
    {"AttributeName":"ts","AttributeType":"N"}], 
"TableName":"table4","KeySchema": 
[{"AttributeName":"userid","KeyType":"HASH"},{"AttributeName":"ts","KeyType":"RANGE"}], 
"TableStatus":"ACTIVE", 
"CreationDateTime":"2016-05-31T12:46:08.351Z", 
"ProvisionedThroughput":{"LastIncreaseDateTime":"1970-01-01T00:00:00.000Z","LastDecreaseDateTime":"1970-01-01T00:00:00.000Z","NumberOfDecreasesToday":0, 
"ReadCapacityUnits":10,"WriteCapacityUnits":10}, 
"TableSizeBytes":15,"ItemCount":1,"TableArn": 
"arn:aws:dynamodb:ddblocal:000000000000:table/table4"}} 
+0

これで問題は解決しますか?はいの場合は、答えを受け入れることができますか? – notionquest