nosql - How to setup Tables in DynamoDB to be able to query a string set/List? -
currently, have table in dynamodb schema:
id : postid (hash key)
location : locationid (range key)
tags: list of strings
now want able query tags list , each item in table , find posts have tags. how do that? reading on dynamodb docs, figure have set table since query cannot search specific strings in list/string set not able figure out how structure table.
for example, item:
postid: guid
location: somelocationstring
tags: ["queen", "royalty", "england"]
now want query items have tag called "queen" , want result set of items has tag. (postid + location)
what optimal structure? , how maintain table when adding new tags?
if understand requirements correctly can go table:
hash: tag
range: postid#locationid
that way can query on tag , pairs.
keeping both tables in sync not optimal depends how atomicity important you. perhaps @ dynamodb transactions, or "cas" inserts.
Comments
Post a Comment