How to use mongoDB with Solr?

Is it possible to replicate data from mongoDB to Solr? I am using ruby ​​+ sinatra + mongoid. Or I need to make hooks with after_create, after_update, etc. Via rsolr?

+7
source share
4 answers

10gen introduced Mongo Connector, which allows you to embed data in Solr (among others)

http://blog.mongodb.org/post/29127828146/introducing-mongo-connector

From my example:

python mongo_connector.py -m localhost:27217 -t http://localhost:8080/solr 
+12
source

Some people have integrated Solr with MongoDB with application code by listening to the "oplog" of MongoDB. I would recommend implementing something in an application completely separate from MongoDB. If the application inserts something into MongoDB, then insertion starts in Solr, etc.

As an alternative

http://jwage.com/2011/03/16/mongodb-tailable-cursors/

but they only work with private collections.

+2
source

I'm not sure if it's too late. Mongo-jdbc will not work with DIH Apache Solr, you will need to expand it. I expanded it and you can use it here: https://github.com/hrishik/solr-mongodb-dih

You can use it directly with Apache Solr. In this case, the DIH configuration file will look something like this:

 <dataConfig> <dataSource name="mongod" type="JdbcDataSource" driver="com.mongodb.jdbc.MongoDriver" url="mongodb://localhost/exampledb"/> <document> <entity name="nameage" dataSource="mongod" query="select name, price from grocery"> <field column="name" name="name"/> <field column="name" name="id"/> <!-- other fileds --> </entity> </document> </dataConfig> 
+2
source

Configure the JDBC attribute of the data import handler using the JDBC driver found at https://github.com/erh/mongo-jdbc - it supports selection, insertion, updating, and drop. Hope this helps!

+1
source

All Articles