产品目录搜索 - NoSQL / MongoDB 的良好用例?
我们正在开发一个要部署在 AppHarbor 上的 ASP.NET MVC 3 网站。该网站上将至少有 10,000 种产品。用户可以基于标签系统搜索产品(例如搜索“颜色=蓝色”加上“尺寸=10”加上“类别=任何”)。因此,这个系统将重于数据库读取而轻于写入,我们主要关心的问题之一是保持搜索功能的速度极快。为此,我们还希望合并一些结果缓存。
我们认为这是使用 NoSQL 数据库的一个很好的用例是对还是错(我们一直在研究 MongoDB,托管在 https://mongohq.com)?
如果我们确实使用 MongoDB,我们应该考虑什么缓存策略?
干杯!
We're developing an ASP.NET MVC 3 website to be deployed on AppHarbor. The site will have at least 10,000 products on it. The user can search for products based on a tagging system (eg search for "color=blue" plus "size=10" plus "category=whatever"). So this system will be heavy on the db reads and light on the writes, and one of our main concerns is to keep the search feature blisteringly fast. To this end we'd also like to incorporate some caching of results.
Are we right or wrong in thinking this a good use case for using a NoSQL database (we've been looking at MongoDB, to be hosted on https://mongohq.com)?
If we do use MongoDB, what caching strategies should we look into?
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MongoDB 非常适合标记,因为它具有多键 功能,
例如假设您像这样创建产品文档,
然后您可以在标签数组上创建索引,并且每个项目都将被索引。因此,要查找所有蓝色产品,您可以这样查询:
这样做的好处是每个项目都可以有一组完全不同的标签“属性”,并且查询将能够使用索引 - 有些可能有颜色和尺寸,其他人可能有体重和身高。
关于缓存,在 MongoDB 中,拥有足够的 RAM 非常重要,以便能够将工作集保存在内存中(足以保存所有访问的数据和索引)。这样,数据将保留在内存中,从而使查询速度非常快。所以你可能不需要顶层的缓存技术。
MongoDB is great for tagging because of it's multikeys functionality
e.g. suppose you create your product documents like this
You can then create an index on the tags array and each item will be indexed. So, to find all products that are blue, you could query like this:
The great thing about this is every item can have a completely different set of tag "attributes" and queries will be able to use the index - some might have color and size, others might have weight and height.
With regard to caching, in MongoDB it's important to have enough RAM to be able to keep your working set in memory (enough for all the accessed data and indexes to be held). This way, data will remain in memory making queries very quick. So you may not need a caching technology on the top.
虽然 MongoDB 可以满足您的需求,但我会认真考虑考虑 Lucene 或 Solr,它们本质上更擅长搜索。它们提供了非常强大的搜索功能,例如分面搜索和“您的意思是……”类型的功能,而 MongoDB 没有而且可能永远不会。
您今天可能不需要这种功能,但花点时间考虑一下您将来是否需要这种功能。
While MongoDB will do what you are looking for, I would seriously consider looking into Lucene or Solr which are inherently better at doing searching. There are very powerful searching features that they provide, like faceted searching and "Did you mean ..." type of functionality, that MongoDB doesnt do and likely never will.
You may not need that kind of functionality today, but take a minute to think about whether or not that is something you may need in the future.