全文檢索引擎(五)---solr與mongodb同步

本篇採用mongo-connector進行mongodb與solr的同步。mongo-connector是用Python語言寫的一個同步程序,使用mongo-connector能夠在不侵入原有系統代碼的狀況下實現數據同步到solr(或者es)中。html

mongo-connector github地址:github.com/mongodb-lab…python

1.安裝python環境

安裝python(3.7.0)git

安裝pip(18.0) 參考:windows安裝pipgithub

2.安裝mongo-connector

安裝mongo-conncector,使用pip執行命令:mongodb

pip install 「mongo-connector」windows

3.開啓mongodb副本集

參考:如何開啓mongodb副本集ui

4.修改solr配置

按需求修改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" />  
複製代碼

5.啓動mongodb-connector

mongo-connector --auto-commit-interval=0  -d solr_doc_manager -t http://localhost:8983/solr/new_core
複製代碼

6.查看結果

相關文章
相關標籤/搜索