Is it possible to ORDER results with query or scan in DynamoDB?

前端 未结 6 769
长发绾君心
长发绾君心 2020-12-04 16:42

Is it possible to ORDER results with Query or Scan API in DynamoDB?

I need to know if DynamoDB has something like [ORDER BY \'field\'] from SQL queries?

Tha

6条回答
  •  死守一世寂寞
    2020-12-04 16:58

    Another option which should solve the problem is to

    1. Define a local secondary index with the "normal" hash key to be the hash key of the LSI as well
    2. Define the field you want to sort as "Sort Key" of the LSI
    3. Query the LSI and set the ordering as desired (see above)

    This will enable sorting of any value of your table as required. It is a very efficient way to find the highest ranking items in your table without the need to get the whole query and then filtering it afterwards.

提交回复
热议问题