Mongodb is a nosql db and any query can be run on it except full text search since it reduces the overall performance. Solr is a search engine to search. When we integrate these two together then dont we have the same data in both systems? So if we already going to store the data anyway why we dont store it directly in solr and lucene. Btw i am not sure when if solr stores only index or together with data.
4 Answers
ok now i know the reason since only the fields we have configured in Solr will be stored in lucene we are not storing the whole data in lucene also. We only store the the search criteria fields in lucene. They are more like completing each other. To explain with an example lets say i have a document having 40 fields and 5 of them are another documents. Imagine I want to make a query saying that i want 3 specific field in document to be equal to a certain value and in one of the child document of parent table i have another criteria for a specific field to be in an interval and 1 another to include certain word. For that rather then having extra indexes in mongodb, I can store only these fields in solr by configuring solr properly.

- 959
- 10
- 21
I might be late to the party but here is my reason why I have started using solr with mongo.
Reason being, I store nested data in mongodb hence the queries are too slow even after indexing as per guide from mongodb. Hence now we started using solr for search, mongodb to store data and another collection in solr for some ranking based search.
We do not store full data in solr for search just filter fields and ID and we leverage redis as cache to get data by ID.

- 2,256
- 2
- 33
- 51
-
i have already set my configuration which is working but problem is why would need mongo for that what it buys you – fatih tekin Apr 25 '14 at 13:42
-
In my case, the Mongo is a usual data store (data base). But i had a need to do ф full text search by documents. Solr geve more performance and flexibility for search. See [comparison]( http://stackoverflow.com/questions/3215029/nosql-mongodb-vs-lucene-or-solr-as-your-database) – jmen7070 Apr 25 '14 at 13:59
I am not MongoDB expert, but judging from this blog post, MongoDB full text search is pretty basic, much like in relational databases. This might be sufficient for you or might be not. Search features offered by Lucene/Solr are far ahead.
Note that you can also Lucene/Solr as a primary storage engine. Lucene offers ACID as well as durability after crashes.

- 26,463
- 15
- 97
- 154
-
thank you for your wisdom but my question is why people integrates them together i mean why would you store same data in different systems which makes me wonder. Is there such thing like store index in solr and store data in mongodb. When we use solr do we default use lucene? – fatih tekin Apr 25 '14 at 11:52
-
1Simple, they might want to use Mongo as the primary data source and Lucene/Solr as the search frontend because basic search feature in Mongo is not sufficient. – mindas Apr 25 '14 at 11:54
-
ok things getting a little bit clear. Then why they do store this data in both systems why they just dont cluster solr. When using mongodb as primary data source what mongo buys you? Sorry i know i am asking too much but i just wonder. – fatih tekin Apr 25 '14 at 11:56
-
Could be legacy reasons since when Mongo did not support search. Could be that Mongo is easier to backup, hard to tell. – mindas Apr 25 '14 at 12:56