0

I have dynamoDB table for order processing with following structure.

enter image description here

I have few more properties and I want to filter orders based on the status. For now I used scan method to get orders based on the status. But I would like to implement query statement to achieve more efficiency during query execution for this. How can I implement query statement to filter orders based on the status property ?

Thank you

Prasad
  • 125
  • 2
  • 3
  • 13

1 Answers1

0

You need a GSI with STATUS as the partition key...

Then in the query, you tell it to use the GSI.

{
    "TableName": "YourTable",
    "IndexName": "StatusIndex",
    "KeyConditionExpression": "status = :v_status",
    "ExpressionAttributeValues": {
        ":v_status": {"S": "FILLED"}
    },
}
Charles
  • 21,637
  • 1
  • 20
  • 44