Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

I had some experience with the integration Solr and MongoDB.

I used Mongo as a data store. And Solr acted as search engine (server). Because, Solr gave me more flexible full text search.

Here and here you can see how to index a mongo data base by Solr.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top