本篇採用mongo-connector進行mongodb與solr的同步。mongo-connector是用Python語言寫的一個同步程序,使用mongo-connector能夠在不侵入原有系統代碼的狀況下實現數據同步到solr(或者es)中。html
mongo-connector github地址:github.com/mongodb-lab…python
安裝python(3.7.0)git
安裝pip(18.0) 參考:windows安裝pipgithub
安裝mongo-conncector,使用pip執行命令:mongodb
pip install 「mongo-connector」
windows
參考:如何開啓mongodb副本集ui
按需求修改managed-schema(老版本叫scheme.xml)把其中的 <uniqueKey>id</uniqueKey>
換成<uniqueKey>_id</uniqueKey>
spa
而後參照其餘blog,添加.net
<field name="_id" type="string" indexed="true" stored="true" />
<field name="_ts" type="long" indexed="true" stored="true" />
<field name="ns" type="string" indexed="true" stored="true"/>
複製代碼
並註釋掉code
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
複製代碼
mongo-connector --auto-commit-interval=0 -d solr_doc_manager -t http://localhost:8983/solr/new_core
複製代碼