Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dynamodb query: Can I use beginswith filter?

I am trying to query a dynamodb table. When I'm using the begins with operator I'm getting the following error.

{u'Message': u'All queries must have a condition on the hash key, and it must be of type EQ', u'__type': u'com.amazon.coral.validate#ValidationException'}

result_set = tb_places.query_2(
    place_name__beginswith="ame",
)

Here place_name is a Global Secondary Index

like image 933
harryjohn Avatar asked Dec 06 '22 22:12

harryjohn


1 Answers

Regardless if you are querying a table or index, the only operator that can be applied to a Hash Key attribute is the EQ. Alternatively, you could use BEGINS_WITH on a Range Key.

For a query on a table, you can have conditions only on the table primary key attributes. You must provide the hash key attribute name and value as an EQ condition. You can optionally provide a second condition, referring to the range key attribute.[...]

For a query on an index, you can have conditions only on the index key attributes. You must provide the index hash attribute name and value as an EQ condition. You can optionally provide a second condition, referring to the index key range attribute.

Source: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html

like image 193
b-s-d Avatar answered Dec 29 '22 17:12

b-s-d