7

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?

Community
  • 1
  • 1
Legend
  • 113,822
  • 119
  • 272
  • 400

2 Answers2

1

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
  • 625
  • 8
  • 18
1

I think the answer you're looking for is really here on your other question: Is there any multicore exploiting NoSQL system?

There is no way to query across all collections in Mongo. It wouldn't make a lot of sense to do so. MongoDB's strength is focused on 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.

Community
  • 1
  • 1
Gates VP
  • 44,957
  • 11
  • 105
  • 108
  • In elasticsearch you can query across multiple indexes, and it's very useful, so don't think it's a general nosql thing. – Peter Ajtai Dec 01 '16 at 00:58