我有一张桌子,上面写着位置和下面的结构
|Location(Hashkey-String)|TimeStamp(Range-Numeric)|#visiting_Person|
现在我想让所有来访的人在两个时间戳之间
Table myTable= Table.LoadTable(client, "tableName");
QueryFilter filter = new QueryFilter();
filter.AddCondition("TimeStamp", QueryOperator.GreaterThan, 56545454);
Search search = myTable.Query(filter);但它会造成错误-
查询条件丢失模式项目:位置
由于错误,我似乎必须在过滤器中添加位置(因为它是散列键),但是我不必对特定位置进行筛选,我必须在时间戳内得到任何位置。
我尝试将时间戳设置为hashkey,但我发现我们只能在hashkey上应用相等的运算符。
在以其他方式进行调试和更改时,我遇到了其他错误,即不能应用键条件。
--我也能对扫描做同样的事情,但由于性能原因,我必须使用查询.。
请告诉我如何才能达到我想要的输出。
发布于 2015-05-20 22:20:09
查询需要表的主键,因此没有一种方法只对范围键进行查询。
基本上,由于基于散列键和查询的DynamoDB分区在分区内运行,您需要这样做:
- Suppose the maximum range between the 2 timestamps is 1 day, you could:
- make an attribute (say "TimeStampDate") that is at date level granularity rather than date+time timestamp granularity.
- make a GSI with TimeStampDate as the Hash key
- execute parallel queries on the dates that overlap the queried time range: "TimeStampDate=[start timestamp date] AND TimeStamp BETWEEN [start timestamp / end timestamp]", "TimeStampDate=[start timestamp date + 1 day] AND TimeStamp BETWEEN [start timestamp / end timestamp]", etc.
https://stackoverflow.com/questions/30349195
复制相似问题