DynamoDB OrderBy操作

时间:2017-07-20 05:52:48

标签: amazon-dynamodb

Table : Customer

Item: CustomerId,PurchaseType,Name,mobilenumber,price, createdDate

DATA1: cus001,"online","BBBBB","yourmobilenumber",6000,"01/07/2017 01:12:05"
DATA2: cus002,"online","myname","mymobilenumber",500,"10/07/2017 01:12:01"
DATA3: cus003,"online","AAAAA","yourmobilenumber",6000,"10/07/2017 01:12:06"
DATA4: cus004,"online","yourname","yourmobilenumber",1000,"10/07/2017 02:12:06"
DATA5: cus005,"retail","yourname","yourmobilenumber",1000,"10/07/2017 03:12:06"

GSI:价格指数[PurchaseType,price]

使用索引查询"价格指数"

条件:purchasetype =" online"和价格> 500

ScanIndex:true

如何根据以下条件获得结果:

purchasetype ="在线" 价格> 500 按名称排序

1 个答案:

答案 0 :(得分:0)

您需要创建一个不同的 GSI

PurchaseType - GSI的分区键

名称 - GSI的排序键

然后,您可以使用查询查找具有必要购买类型的所有商品,按名称排序,并提供filter expression来过滤所有价格较高的商品。