我有以下AWS DynamoDB表:
分区键|排序键
价格|时间戳|
以下全球二级指数(GSI):
分区键|排序键|
产品|价格|
以下查询参数:
var qparams = {
TableName : pricetable,
IndexName : "product-price-index",
ConsistentRead: false,
ScanIndexForward: true,
KeyConditionExpression: "#product = :product and #price <= :price",
ExpressionAttributeNames:{
"#product": "product",
"#price" : "price"
},
ExpressionAttributeValues: {
":product": productname,
":price" : productprice
}
};
查询结果根据ScanIndexForward = true / false的价格按升序或降序排序 .
我最终想要的是一个查询结果,其中包含具有价格和时间戳的产品,其中主要排序顺序是相应的价格,同一价格中的排序顺序是根据时间戳,总是在升序 .
例如 . :
上涨价格:价格|时间戳
8300 | 1518609990106 8300 | 1518609990106 8410 | 1518612998669 8410 | 1518613154893
降价:
价格|时间戳
8410 | 1518612998669 8410 | 1518613154893 8300 | 1518609990106 8300 | 1518609990106
这样做的最佳解决方案是什么?
感谢您的支持!