dynobase-icon
Dynobase

Error: DynamoDB Contains not working

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

contains works on a String, Set, or List. It checks a substring for strings and membership for collections. It is allowed in filter and condition expressions, not in a Query KeyConditionExpression. A Number attribute itself is not a searchable collection.

import boto3
from boto3.dynamodb.conditions import Key, Attr

table = boto3.resource("dynamodb", region_name="us-east-1").Table("Orders")
page = table.query(
    KeyConditionExpression=Key("pk").eq("CUSTOMER#123"),
    FilterExpression=Attr("tags").contains("priority"),
)
print(page.get("Items", []))

For a string set, pass one string, not a set containing that string. For a number set, pass a number of the appropriate client representation. For strings, matching is case-sensitive. To search a nested field, address that field rather than passing an entire map to contains.

Filters run after the key-based read and do not reduce its read capacity. Continue through LastEvaluatedKey even when a page contains no matches. Use begins_with for a supported sort-key prefix condition; contains cannot turn an arbitrary substring search into an indexed Query.

See expression builder and AWS documentation.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Changelog
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.