Reputation: 581
When I try to use QueryRequest
of amazon-dynamodb
through indexname it says
Query Key not supported
How to query two global secondary index? Is it possible?
Upvotes: 2
Views: 3466
Reputation: 55720
You can't query using more than one index at the same time. Fundamentally, using more than one index to make a single query just doesn't make any sense.
Perhaps you meant to ask if you could use different indexes to perform different queries on the same table in which case the answer is yes.
Or perhaps you meant to ask whether you can perform a complex query that involves joining or otherwise filtering data using multiple indexes, in which case the answer is unfortunately, no - not in a single query, at least. DynamoDB doesn't support serverside joins. You have to make multiple queries (which can each use a different index) and then aggregate client-side.
-- Update
Based on the error you said you are getting it looks like you haven't correctly specified the hash/range key(s) for your query using a global secondary index.
Have a look at the docs for instructions on how to query with a secondary index: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html#GSI.Querying
Upvotes: 3