Still trying to wrap my head around the right way to structure data in dynamodb. There are scalars, documents, and sets. I’m not clear on why the distinction of documents and sets. Also I find the Query and Scan documentation impenetrable.
Anyway, there are several fields that I’d like to be multi-valued associated with a media object, namely tags and location hierarchy. (tags is obvious, but location hierarchy might require a bit of unpacking, it just means that I want to store the fact that a photo is taken in Bali and also in Indonesia and also in Gianyar such that I can ask for photos taken in Bali)
It seems like the right way to do this in Dynamodb is to use Scan. It is so weird that the correct pattern is a full table Scan. Every aspect of my MySQL scaling experience cries out in horror. I could build a secondary index around tags and another around geo, but then I have to pay for the throughput for that index, which isn’t something I’m going to be querying often.
store a set of strings (StringSet) in Dynamodb using Boto3
table.update_item(
Key={'path_md5':path_md5},
UpdateExpression="set Colors=:c",
ExpressionAttributeValues={':c' : set(['Black', 'Green'])})
And then to pull it back out again
resp = table.scan(
FilterExpression=Attr('Colors').contains('Green')
)