2014-07-23 77 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和範圍鍵的比較謂詞提供確切的值。