In one of my python application, I am using boto and I want to query a dynamodb table using range key only. I don't want to use scan.
Schema for ratings table
ratings = Table.create('ratings', schema=[
HashKey('user_id', data_type=NUMBER),
RangeKey('photo_id', data_type=NUMBER)
], throughput={
'read': 5,
'write': 15,
}, indexes = [
AllIndex('rating_allindex', parts=[
HashKey('user_id', data_type=NUMBER),
RangeKey('photo_id', data_type=NUMBER)
])
])
from boto.dynamodb2.table import Table
ratings = Table('ratings')
# photo_id is range_key and user_id is hash_key
ratings_list = ratings.query(photo_id__eq=1)
On doing so, I get this error Query condition missed key schema element user_id
.
Again, I thought I could give a filter condition to my hash_key
ratings_list = ratings.query(user_id__gte=1, photo_id__eq=1)
But it showed the error, Query key condition not supported
. I suppose only the filter __eq is allowed with hash_key. How do I achieve what I want?