Mongo-connector集成MongoDB到Solr實現(xiàn)增量索引

Mongo-connector集成MongoDB到Solr實現(xiàn)增量索引

站在用戶的角度思考問題,與客戶深入溝通,找到梧州網(wǎng)站設計與梧州網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設計與互聯(lián)網(wǎng)技術結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都做網(wǎng)站、網(wǎng)站建設、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名與空間、虛擬空間、企業(yè)郵箱。業(yè)務覆蓋梧州地區(qū)。

 

配置MongoDB復制集

參考:《部署一個用于測試和開發(fā)的復制集》

安裝Solr5.3

參考:《在CentOS下安裝Solr5.3》

安裝Python2.7

參考:《在CentOS下安裝Python2.7》

安裝pip

參考:《在CentOS下安裝pip》

安裝mongo-connector


方法一:使用pip安裝

pip install mongo-connector

安裝到了python的默認包目錄下:

/usr/local/lib/python2.7/site-packages

方法二:安裝為服務

1. 去https://github.com/mongodb-labs/mongo-connector/archive/master.zip下載mongo-connector-master.zip。

2. 解壓縮進入目錄。

unzip mongo-connector-master.zip
cd mongo-connector-master

3. 編輯配置文件。

vi config.json

4. 安裝為服務。

python setup.py install_service

在/etc/init.d下創(chuàng)建了mongo-connector服務,并拷貝config.json文件到/etc/mongo-connector.json。

卸載mongo-connector服務

python setup.py uninstall_service

它將移除/etc/init.d/mongo-connector和/etc/mongo-connector.json

查看服務狀態(tài)

service mongo-connector status

配置Solr


在Solr數(shù)據(jù)目錄/data/solr/data/下有Solr配置文件solr.xml

創(chuàng)建core

su - solr -c "/usr/local/solr/solr/bin/solr create -c card -n data_driven_schema_configs"

生成了文件夾/data/solr/data/card,在/data/solr/data/card/conf目錄下是card的配置目錄,可以配置同義詞、停止詞。

配置solrconfig.xml

1. 確保啟用了LukeRequestHandler

以下行應用出現(xiàn)在solrconfig.xml文件中。

<requestHandler name="/admin/luke" class="org.apache.solr.handler.admin.LukeRequestHandler" />

2. 配置硬提交(刷新到硬盤上的頻率)和軟提交(提交到內(nèi)存中的頻率)

在solrconfig.xml文件中配置<autoCommit>和<autoSoftCommit>

<autoCommit>
<maxTime>300000</maxTime>
<maxDocs>10000</maxDocs>
<openSearcher>true</openSearcher>
</autoCommit>
<!-- softAutoCommit is like autoCommit except it causes a
'soft' commit which only ensures that changes are visible
but does not ensure that data is synced to disk. This is
faster and more near-realtime friendly than a hard commit.
-->
<autoSoftCommit>
<maxDocs>1000</maxDocs>
<maxTime>60000</maxTime>
</autoSoftCommit>

配置schema.xml

1. Mongo Connector存儲元數(shù)據(jù)在每個文檔中幫助處理回滾。為了支持這些數(shù)據(jù),你需要添加如下信息到你的schema.xml中:

<field name="_ts" type="long" indexed="true" stored="true" />
<field name="ns" type="string" indexed="true" stored="true"/>

2. 在schema.xml中配置配置<uniqueKey>、<field>

啟動mongo-connector


方法一:以命令行啟動

nohup sudo mongo-connector -m localhost:27019 -t http://localhost:8983/solr/card -o oplog_progress.txt -n example.card -u _id -d solr_doc_manager > mongo-connector.out 2>&1

方法二:以服務啟動

service mongo-connector start

Solr刪除全部索引


http://192.168.11.52:8983/solr/card/update/?stream.body=%3Cdelete%3E%3Cquery%3E*:*%3C/query%3E%3C/delete%3E&stream.contentType=text/xml;charset=utf-8&commit=true

參考:

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

https://github.com/mongodb-labs/mongo-connector/wiki/Installation

https://github.com/mongodb-labs/mongo-connector/wiki/Usage-with-Solr

https://loutilities.wordpress.com/2012/11/26/complementing-mongodb-with-real-time-solr-search/

網(wǎng)站名稱:Mongo-connector集成MongoDB到Solr實現(xiàn)增量索引
鏈接URL:http://muchs.cn/article18/gppjdp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站品牌網(wǎng)站建設、移動網(wǎng)站建設網(wǎng)站維護、網(wǎng)站設計、虛擬主機

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作