The format of my data looks like this
{
ID:'some uuid'
Email:'[email protected]',
Tags=[tag1,tag2,tag3...],
Content:' some content'
}
The partition key is ID and the sort key is Email I created a secondary index of email which is "email_index" if I only want to query by Email, Now I want to query data both by Email and by a specific tag For example I want to find all data that Email='[email protected]' and Tags contains 'tag2', I want to first query by "email_index"
result=table.query(
IndexName='EmailIndex',
KeyConditionExpression='Email=:email',
ExpressionAttributeValues={
':email':'[email protected]'
}
)['Items']
then scan the result with Attr('Tags').contains('tag2')
So is it possible to do both at the same time? Or I have to write a loop to filter query results in Python?
Tagsattribute to theEmailIndexas a sort key?