How to query dynamoDB without using hashKey
How to query dynamoDB without using hashKey
I have a dynamoDB table with two attributes:
A: primary partition key
B: primary sort key
I want to query this table using attribute B since I don't know the value of A. Is it possible to do so?
Is it possible to make B as GSI (global secondary index), how to do and query the table using B, since B is already a sort key.
1 Answer
1
You need partition-key to query - you can't do it using sort-key alone. You can only scan.
So, the only way out for you is to create a GSI with B as the partition-key.
Update
Yes, you can use range-key as GSI.
The drawback to using GSI are:
please check update
– Kaidul
Sep 17 '18 at 21:41
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
is it possible to make range key as GSI-partition key @DynamoDBRangeKey and @DynamoDBIndexHashKey(attributeName = B, globalSecondaryIndexName = B_index)
– pjain
Sep 17 '18 at 21:28