我使用的是: dynamodb2,boto,python。我有以下用于创建表的代码:
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)谢谢!
发布于 2014-07-24 05:47:18
如果要添加其他范围关键点,则需要使用Local secondary index。
查询LSI的方式与查询基表的方式相同。您需要为hashkey提供一个确切值,并为范围键提供一个比较谓词。
https://stackoverflow.com/questions/24900221
复制相似问题