我在做一个POC来展示卡桑德拉的工作原理。我以Digg为例。我想要创建一个数据模型,让我:
1)添加链接2)添加到用户喜爱列表的链接。3)将预定的标签附加到链接上
我想出了两个专栏家庭:
- url is the key
- id (a generated uuid)
- user (who added it)
- favCount (no of users who favorited the link)
- upCount (no of users who liked it)
- downCount (no of users who disliked it)
- user is the key
- id (as many ids as the user has favorited)
这对于上面的需求#1和#2来说很好,但是当我谈到#3时,它就变得更棘手了。我可以添加诸如'java‘、'languages’、'architecture‘这样的标签,作为列名,链接列族中的值为空。但是查询需要很长时间,假设我要查找所有标记在'java‘下的链接。
有人能就如何实现这个问题提出一些想法吗?
如果我对这个问题不清楚,请告诉我。
谢谢,库马尔
发布于 2011-12-11 19:45:44
您可以创建一个辅助索引,即按标记键的列系列。每行包含该特定标记的所有链接。请注意,这可能会导致非常宽的行(即有许多列),每个行都将存储在单个cassandra节点上。如果它们变得很大,你可能想要一个把它们分开的计划。
请参阅http://www.datastax.com/docs/0.7/data_model/cfs_as_indexes
或http://pkghosh.wordpress.com/2011/03/02/cassandra-secondary-index-patterns/
或者google cassandra secondary index
https://stackoverflow.com/questions/8466553
复制相似问题