What's the best way to filter results with the begins_with method for boto3.dynamodb.condition.Key?
import boto3
from boto3.dynamodb.conditions import Key
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('MyTable')
response = table.query(KeyConditionExpression=Key('myPrimaryKey').begins_with('americas'))
The results, although conditions supports begins_with, is the query is not supported. Can you not use begins_with on primary or sort keys?
Primary keys in DynamoDB can be either simple or composite .
Simple primary keys are consist of a partition key and no sort key.
Composite primary keys have both a partition key and a sort key.
You can only use begins_with
on the sort key, not the partition key.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.