2

How can I make a query using more than one value? For example, all users with last_name ["Doggett","Scully","Mulder"]

Example using boto.

    Table.create('users', 
        schema=[
            HashKey('id') # defaults to STRING data_type
        ], throughput={
            'read': 5,
            'write': 15,
        }, global_indexes=[
            GlobalAllIndex('LastnameTimeIndex', parts=[
                HashKey('last_name'),
                RangeKey('creation_date', data_type=NUMBER),
            ],
            throughput={
                'read': 1,
                'write': 1,
            }),
        ],
        connection=conn
   )

something like:

table = Table("users", connections=conn)
table.query_2(last_name__in=["Doggett","Scully","Mulder"], connection=conn)

2 Answers 2

3

Currently, the Query API doesn't support the IN condition as a KeyCondition. As suggested by Max, you'll need to make separate queries. You can also make the queries in parallel to improve performance.

If you want to use IN, you'll need to do a scan (or index scan in your example) instead.

Sign up to request clarification or add additional context in comments.

Comments

1

You have to do three separate Queries. One for each last name.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.