存储和检索用户最喜欢的标签
我正在尝试在我的电子商务网站上实施定向营销行为分析。基本思想如下(我假设使用 MongoDB,但期待其他建议):
- 每个网站
Category
都有一个关联的tags
列表, - 每个网站内容
文章
也有一个标签
列表, - 每个
用户
在第一次访问时都有一个分配给他/她的唯一的cookie ID, 每次用户浏览
Category
或读取Article
,我们计划增加User-tag
字典,如下所示:db.tagviews.update( {_id:用户id}, {$inc: {'tags.foo': 1, 'tags.bar': 1, 'tags.baz': 1}}, true /* 更新插入 */ )
因此,如果我们想查看特定用户的兴趣,我们可以为他获取 tagviews
文档,并查看 tags
以查看哪些内容最多意见。
然而,我偶然发现了一件非常琐碎的事情 - 如何根据标签标准获取用户。例如,我们以极具吸引力的价格备有 Google Galaxy Nexus 现货,并希望向对[android、手机、小工具、google]
最感兴趣的用户发送营销电子邮件。
据我了解,我们必须在 tagviews 集合中的每个 tags.*
字段上创建索引,这当然是不可接受的。另一种可能的解决方案是在另一个维度复制数据(增加标签-用户组合而不是用户标签)。但综合测试在磁盘空间和灵活性方面看起来非常没有希望。
您对根据标签标准有效获取最感兴趣的用户有何建议?
谢谢!
I'm trying to implement a behavioral analysis for targeted marketing on my ecommerce website. The basic idea is as follows (I assume the usage of MongoDB, but looking forward for the other recommendations):
- every website
Category
has a list of associatedtags
to it, - every content
Article
also has a list oftags
, - every
User
has an unique cookie ID assigned to him/her on the first visit, every time the user browses a
Category
or reads anArticle
, we plan to increment theUser-tag
dictionary like this:db.tagviews.update( {_id: user_id}, {$inc: {'tags.foo': 1, 'tags.bar': 1, 'tags.baz': 1}}, true /* upsert */ )
So if we want to see the interests of the particular user, we can fetch the tagviews
document for him and look through the tags
to see which ones has the most views.
However, I've stumbled on a pretty much trivial thing - how to fetch users, based on tags criteria. E.g. we've got Google Galaxy Nexus in stock for an attractive price, and want to send marketing emails to the users most interested in [android, phones, gadgets, google]
.
As far as I understand, we have to create indexes on every tags.*
field in the tagviews collection, which is, of course, unacceptable. The other possible solution is to duplicate data in another dimension (incrementing tag-user combo instead of user-tag). But syntetic tests looks very unpromising in terms of disk space and flexibility.
What would be your suggestions to effectively fetch the most interested users based on tags criteria?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的示例中,我了解到您正在使用标签名称作为 tagviews 集合中的键(也称为字段)。
不要这样做,这会让您在需要创建索引时陷入噩梦。相反,您可以在标签视图中创建标签作为嵌入文档
,您可以通过标签名称有效地索引该文档,以便在过滤器中使用它
,并且您可以在用户偶然发现他的兴趣时增加用户的特定标签视图
。
所以对于你真正的问题,
您可以像这样过滤它
,这将检索对上述标签感兴趣的所有用户。
或者甚至您可以使用计数来过滤最准确的数据
希望这有帮助
From your example i understand that you are using tag names as keys (aka fields) in tagviews collection.
Dont do that , which leaves you in the nightmare when you need to create indexes. Instead create tags as embedded doc within tagviews
and you can effectively index this document by tag name to use it in your filters
And you can increment the specific tag view of a user by
when your user stumbled on his interests.
So to your real question,
you can filter it like
This will retrieve all the users who are interested in above said tags.
or even you can use count to filter most accurate data
hope this helps