1

I have the following sort key in a dynamo db table:

YYYY-MM-DD#<USER_ID>#<CATEGORY_ID>

Im trying to solve the following two access patterns:

  1. get all item for a user in the last x days
  2. get all items for a user and category in the last x days

I can satisfy the 2nd access pattern with the following conditional expression:

sort_key BETWEEN 2018-01-02#<USER_ID>#<CATEGORY_ID> and 2019-01-02#<USER_ID>#<CATEGORY_ID>

This returns several items between 2018-01-02 and 2019-01-02

However, if I try to satisfy the 1st access pattern I cant get it to work. I've tried:

sort_key BETWEEN 2018-01-02#<USER_ID> and 2019-01-02#<USER_ID>

But only one item is returned, the item with date 2018-01-02, but I should be getting multiple items returned.

I searched online for any wildcard operators with conditional expression, but couldn't find any. Any ideas how I can satisfy access pattern 1?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.