dynamodb how to query by sort key only?

scott picture scott · Feb 21, 2017 · Viewed 21.9k times · Source

I have written some python code, I want to query dynamoDB data by sort key. I remember I can use follow-up code successful:

 table.query(KeyConditionExpression=Key('event_status').eq(event_status))

My table structure column

primary key:event_id
sort key: event_status

Answer

man2xxl picture man2xxl · Aug 17, 2018

You have to create a global secondary index (GSI) for the sort key in order to query on it alone.