Is Product Catalog Search a Good Use Case for NoSQL / MongoDB?

We are developing an ASP.NET MVC 3 website for deployment on AppHarbor. There will be at least 10,000 products on the site. The user can search for products based on the tag system (for example, the search for "color = blue" plus "size = 10" plus "category = whatever"). Thus, this system will be hard to read db and illuminate the records, and one of our main problems is to support the search function quickly. To this end, we would also like to enable some caching of results.

  • Right or wrong, we think this is a good use case for the NoSQL database (we looked at MongoDB, which was hosted at https://mongohq.com )?

  • If we use MongoDB, what caching strategies should we look for?

Hooray!

+4
source share
2 answers

MongoDB is great for tagging because of this multikeys functionality

eg. suppose you create your product documents like

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

Then you can create an index in the tag array and each item will be indexed. So, to find all the blue products, you can request the following:

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

The great thing about this: each element can have a completely different set of β€œtag” attributes, and queries will be able to use an index β€” some may have color and size, others may have weight and height.

As for caching, in MongoDB it is important to have enough RAM to store your working set in memory (enough for all available data and indexes). Thus, the data will remain in memory, making queries very fast. Thus, you may not need caching technology from above.

+7
source

While MongoDB will do what you are looking for, I would seriously consider looking at Lucene or Solr, which in essence perform better searches. There are very powerful search functions that they provide, for example, faceted search and the type β€œDid you mean ...” that MongoDB does not and probably never will.

Today you may not need this functionality, but think about whether you really need it in the future.

+1
source

All Articles