views:

44

answers:

2

I am inserting my data into MongoDB and had 240 such files. Instead of inserting everything into one big collection, I was thinking of inserting the files as a collection by themselves. Is this a good idea if I do a lot of queries on a commonly indexed column?

If so, how can I initiate a query to query all the collections in my database?

A: 

Using an application server such as Solr can help you achieve what you want, also with the addition of fuzzy matching, synonyms, phonetic matching, misspellings, etc.

Solor is built on top of Lucene. It's docs are here:

http://lucene.apache.org/solr/

The learning curve is a little bit steep, but you can get pretty good searchability using much of its defaults, leaving you to build a schema and index your data to get started.

Chris Adragna
A: 

I think the answer you're looking for is really here on your other question: http://stackoverflow.com/questions/3848120/

There is no way to query across all collections in Mongo. It wouldn't make a lot of sense to do so. Mongo (and NoSQL in general) is about tactically denormalizing data into collections. Providing operations to query across all collections run exactly counter to the concept of tactical denormalization.

In theory, you could just run 240 queries. But more practically you'll probably end up "partitioning" your data so that you only need to query some of the collections. At this point you end up back at the link I provided above, which suggests that sharding your data is probably the answer here.

Gates VP