How to use mongoDB with Solr?

后端 未结 4 1700
孤城傲影
孤城傲影 2020-12-25 09:55

Is it possible to replicate data from mongoDB to Solr? I\'m using ruby + sinatra + mongoid. Or i need to make hooks with after_create, after_update and so on through rsolr?<

相关标签:
4条回答
  • 2020-12-25 10:27

    10gen introduced Mongo Connector, which allows to push data into Solr (among others)

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

    From their example:

    python mongo_connector.py -m localhost:27217 -t http://localhost:8080/solr
    
    0 讨论(0)
  • 2020-12-25 10:28

    Some people integrated Solr with MongoDB with application code listening to the "oplog" of MongoDB. I would recommend implementing something on the application completely decoupled from MongoDB. If you application inserts something into MongoDB then trigger an insertion into Solr etc.

    Tailabled cursors might be an option

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

    but they only work with capped collections.

    0 讨论(0)
  • 2020-12-25 10:30

    I am not sure whether its too late. The mongo-jdbc would not work with DIH of Apache Solr, you would need to extend it. I have extended it, and you can use it from here: https://github.com/hrishik/solr-mongodb-dih

    You can directly use it with Apache Solr. In that case, DIH config file will look something like below:

    <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>
    
    0 讨论(0)
  • 2020-12-25 10:50

    Configure the JDBC flavour of the data import handler using the JDBC driver found at https://github.com/erh/mongo-jdbc -- it supports select, insert, update, and drop. Hope this helps!

    0 讨论(0)
提交回复
热议问题