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:






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







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

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)