2014-07-23 73 views
0

我正在使用以下:dynamodb2,boto,python。我创建表下面的代码:Dynamodb2表架构创建

table = Table.create('mySecondTable', 
schema=[HashKey('ID')], 
RangeKey('advertiser'), 
throughput={'read':5,'write':2}, 
global_indexes=[GlobalAllIndex('otherDataIndex',parts=[ 
    HashKey('date',data_type=NUMBER), 
    RangeKey('publisher', date_type=str), 
],throughput={'read':5,'write':3})], 
connection=conn) 

我希望能够有下列数据,我可以通过查询: ID,广告客户,日期,发行商,大小和颜色

这意味着我需要一个不同的模式。当我添加其他点时,除非列名在模式中列出,否则它不会查询。

但问题是,现在我只能通过Id,广告客户,日期和发布者在这种情况下进行查询。如何添加我可以查询的附加列?

我读这这似乎说,这是可能的: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html

但是这里没有例子: http://boto.readthedocs.org/en/latest/dynamodb2_tut.html

我尝试添加一个额外的一系列重要但是它不工作(不能有重复)

我想它是这样:

table = Table.create('mySecondTable', 
schema=[ 
RangeKey('advertiser'), 
otherKey('date') 
fourthKey('publisher') ... etc 
throughput={'read':5,'write':2}, 
connection=conn) 

谢谢!

回答

0

如果你想添加额外的范围键,你需要使用Local secondary index

您可以像查询基表一样查询LSI。您需要为hashkey和范围键的比较谓词提供确切的值。