产品目录搜索 - NoSQL / MongoDB 的良好用例?

发布于 2024-11-02 07:20:52 字数 394 浏览 4 评论 0原文

我们正在开发一个要部署在 AppHarbor 上的 ASP.NET MVC 3 网站。该网站上将至少有 10,000 种产品。用户可以基于标签系统搜索产品(例如搜索“颜色=蓝色”加上“尺寸=10”加上“类别=任何”)。因此,这个系统将重于数据库读取而轻于写入,我们主要关心的问题之一是保持搜索功能的速度极快。为此,我们还希望合并一些结果缓存。

  1. 我们认为这是使用 NoSQL 数据库的一个很好的用例是对还是错(我们一直在研究 MongoDB,托管在 https://mongohq.com)?

  2. 如果我们确实使用 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.

  1. 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)?

  2. If we do use MongoDB, what caching strategies should we look into?

Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盛夏尉蓝 2024-11-09 07:20:52

MongoDB 非常适合标记,因为它具有多键 功能,

例如假设您像这样创建产品文档,

{
    _id : 1,
    name : "Widget",
    tags: [
        {color : "blue"},
        {size : 10},
        {foo : "bar"}
    ]
}

然后您可以在标签数组上创建索引,并且每个项目都将被索引。因此,要查找所有蓝色产品,您可以这样查询:

db.Products.find({tags : {color : "blue"}});

这样做的好处是每个项目都可以有一组完全不同的标签“属性”,并且查询将能够使用索引 - 有些可能有颜色和尺寸,其他人可能有体重和身高。

关于缓存,在 MongoDB 中,拥有足够的 RAM 非常重要,以便能够将工作集保存在内存中(足以保存所有访问的数据和索引)。这样,数据将保留在内存中,从而使查询速度非常快。所以你可能不需要顶层的缓存技术。

MongoDB is great for tagging because of it's multikeys functionality

e.g. suppose you create your product documents like this

{
    _id : 1,
    name : "Widget",
    tags: [
        {color : "blue"},
        {size : 10},
        {foo : "bar"}
    ]
}

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:

db.Products.find({tags : {color : "blue"}});

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.

枫林﹌晚霞¤ 2024-11-09 07:20:52

虽然 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文