Search code examples
amazon-web-servicesamazon-dynamodbaws-java-sdk-2.xaws-java-sdk-dynamodb

Getting a number of items from a list by pagination in Dynamodb


I have a dynamodb structure like below:

    {
       "PK" : "queue#1234#view",
       "SK" : "board#1234",
       "items" : [
           "1234",
           "1234",
           "1234",
           "1234",
           "1234",
           "1234"
        ]
    }

I want to know if there is a way to use a filter expression in Dynamodb to get range of items from the list for pagination by specifying indexes. For example, I want to get range items from index 0 to 3 and index 2 - 5. I was reading through this doc: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Attributes.html but couldn't find a solution. There is a list expression function: list_append, and I'd like to know if there is a function like list_select[start_index, end_index] or something similar.

enter image description here


Solution

  • There is no real advantage to do a filter on a single item... You pay the same, and the performance is the same. So it's best just to read the entire item and manipulate it on the client side as you wish.