7

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

1
  • If place_name is the hash_key, a query won't work like this. You also didn't specify the index name (index='DateJoinedIndex')
    – mkobit
    Commented Apr 12, 2015 at 20:36

1 Answer 1

22

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.