【发布时间】:2015-03-21 20:52:55
【问题描述】:
在 Dynamodb 中,您需要在索引中指定可用于进行查询的属性。
如何使用两个以上的属性进行查询?
使用 boto 的示例。
Table.create('users',
schema=[
HashKey('id') # defaults to STRING data_type
], throughput={
'read': 5,
'write': 15,
}, global_indexes=[
GlobalAllIndex('FirstnameTimeIndex', parts=[
HashKey('first_name'),
RangeKey('creation_date', data_type=NUMBER),
],
throughput={
'read': 1,
'write': 1,
}),
GlobalAllIndex('LastnameTimeIndex', parts=[
HashKey('last_name'),
RangeKey('creation_date', data_type=NUMBER),
],
throughput={
'read': 1,
'write': 1,
})
],
connection=conn)
如何使用 boto 查找名字为“John”、姓氏为“Doe”并在“2015 年 3 月 21 日”创建的用户?
【问题讨论】:
-
您在索引上查询,可以使用
ConditionExpression进行其他属性比较。我不清楚您的表格现在是如何构成的。 -
您还需要哪些额外信息?你的意思是建表命令不够?
标签: python amazon-web-services amazon-dynamodb boto nosql