Apache Solr 實踐 二 資料庫增量匯入

2021-09-01 21:54:09 字數 1669 閱讀 6658

之前將solr的基礎環境搭建了起來。今天配置一下資料庫的增量匯入。實現步驟wiki上面寫的已經很清楚,主要注意兩點,一是索引的中文分詞,二是自定義字段。solr自帶的schema.xml中已經配置了常用字段,遇不包含字段需要定義。依wiki,實現solr索引定時增量匯入大致需五步。

第一步,配置requesthandler於solrconfig.xml內容如下

./data-config.xml

第二步,編寫data-config.xml和dataimport.properties。solr發布包中隨帶了乙個demo位於solr-4.3.0\example\example-dih\solr\db\conf直接拿來稍作修改

'$'">

'$'"

parentdeltaquery="select id from item where id=$">

'$'"

parentdeltaquery="select id from item where id=$">

'$'"

parentdeltaquery="select item_id, category_id

from item_category where category_id=$">

#fri jan 17 11:44:56 cst 2014

interval=1

port=80

server=localhost

params=/dataimport?command\=delta-import&clean\=false&commit\=true

rebuildindexinterval=2

dataimporter.last_index_time=1914-01-14 17\:40\:00

syncenabled=1

last_index_time=2014-01-17 11\:44\:55

item.last_index_time=2014-01-17 11\:44\:55

rebuildindexparams=/dataimport?command\=full-import&clean\=true&commit\=true

rebuildindexbegintime=03\:10\:00

synccores=collection1

第三步,修改schema.xml支援中文分詞。data-config.xml中filed引用schema.xml中的filedtype,而schema.xml中name,manu等字段類行為text_general,需要改為之前配置的text_zh.

第四步建資料庫,資料庫指令碼也都是現成的,位於solr-4.3.0\example\example-dih\hsqldb\ex.script。demo是基於sqldb的,稍作修改即可用於mysql。將資料庫驅動拷到lib。insert n筆資料(中文)作為測試。

第五步,建索引。依次開啟solr控制台-——>dataimport,command首次選full-import,勾選commit,entity選擇item——>execute。

索引結果如何?在solr控制台左側選擇query,q填寫name:關鍵字,execute query。效果如圖

Apache solr高階 匯入資料庫資料

系統 centos linux release 7.6.1810 jdk openjdk 1.8.0 222 solr版本 solr 7.7.2 資料庫 oracle 11.2.0.4.0 64bit cd solr install home dist 編輯配置檔案solrconfig.xml,在6...

資料結構實踐專案 查詢(二)

本文是 資料結構基礎系列 8 查詢 課程的第二組實踐專案。參考解答 1 給定序列 1 建立對應的3階b 樹b,請畫出構造過程 2 從b中分別刪除關鍵字為8和1的節點,畫出其過程 2 建立序列的雜湊表,裝填因子定為0.8,雜湊函式為h k key p,p 11 1 採用線性探查法解決衝突,請寫出雜湊表...

暑假實踐(二)

aistido社群有許多學習資源,分為入門類 高階類 高階類三個級別。我們可以找到我們感興趣的專案,然後fork一下,將專案複製過來,然後就可以對專案進行修改和新增。fork貓狗分類專案 jupyter notebook 是乙個基於 web 的互動式計算筆記本環境。jupyter notebook ...