I met a really weird question when I was using DynamoDB in the project (with JAVA SDK).
We created a DynamoDB table with a Primary Partition Key 'id', and a Sort Key 'create_time'. And I used query
operation in my source code with both Partition Key and Sort Key, but I get a exception while querying
com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: Query condition missed key schema element: create_time (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: K9B8K5DU0CQ1BQA9VJIPTI6EIJVV4KQNSO5AEMVJF66Q9ASUAAJG)
I have researched for a day, and almost all the results for searching "Query condition missed key schema element" from google told me that I'm not using the Partition Key or GSI in KeyConditionExpression
, but I'm sure that we had set up correct Partition Key and Sort key with correct names and used correct in source code, by the way we didn't create any GSI in out DynamoDB.
So I just want to know that are there any situations which might cause this exception - Query condition missed key schema element with a Sort Key rather than a Partition Key.
**BACKGROUND STATEMENT **
- This
query
operation worked in my develop environment well, but not worked in the production environment. The source code is exactly the same.
- This table is new created in production environment. (I ever suspected that there must be something wrong while creating the table in the production environment. But I have confirmed for several times, the Partition Key and Sort Key are all correctly named and we do not create any GSI.)
- The differences between develop and production might be the DynamoDB regions. Develop is created in ap-southeast-1 and the production is in us-west-1.