dynamodb最早从表中插入不同的值 [英] dynamodb get earliest inserted distinct values from a table

查看:70
本文介绍了dynamodb最早从表中插入不同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Amazon Dynamodb,但经验不足。我有这样的价格表:

I am using Amazon Dynamodb but do not have much experience. I have Prices table like this:

Id |插入日期|产品名称|店铺名称|价格

Id | InsertionDate | ProductName | ShopName | Price

商店名称和产品名称相同的值可以不同(价格和插入日期可能不同)。例如

There can be different values with same shopname and productname, (the price and insertion date might be different). e.g

id1 | 2015-12-14T16:41:42 | Cheese 500g | Shop1 | 2.4
id2 | 2015-12-14T15:41:42 | Cheese 500g | Shop1 | 2.2
id3 | 2015-12-14T12:41:42 | Cheese 500g | Shop2 | 2.1
id4 | 2015-11-14T12:41:42 | Cheese 500g | Shop2 | 2.5

现在我想查询该表,以便按最新的商店获得唯一的值(即插入日期最早)按价格排序。因此,从上面的示例中我想得到这个:

Now I want to query this table so that I get unique values by shops which are newest (i.e the insertion date is earliest) sorted by price. So from above example I want to get this:

id3 | 2015-12-14T12:41:42 | Cheese 500g | Shop2 | 2.1 
id1 | 2015-12-14T16:41:42 | Cheese 500g | Shop1 | 2.4

有什么想法吗?

推荐答案

您无法做到。

您只能查询dynamodb的索引(哈希范围键或全局二级键) )。

you can query dynamodb only on his indexes (hash-range keys, or global secondary keys.)

要查询dynamodb,您至少需要查询哈希键,并且您会在范围键上获得有序的结果(如果有的话)范围键)

in order to query dynamodb, you need at least to query on your 'hash' key, and you will get ordered results on your range key (if you have range key)

http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/Welcome.html

http://www.allthingsdistributed.com/2013/12/dynamodb-global-secondary-indexes.html

这篇关于dynamodb最早从表中插入不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆