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

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

问题描述

我正在使用 Amazon Dynamodb,但没有太多经验.我有这样的价格表:

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

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

Id | InsertionDate | ProductName | ShopName | Price

相同的 shopname 和 productname 可以有不同的值(价格和插入日期可能不同).例如

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

任何想法如何做到这一点?

Any ideas how to do this?

推荐答案

你做不到.

您只能根据他的索引(哈希范围键或全局辅助键)查询 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/最新/gettingstartedguide/Welcome.html

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

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

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