Solr定时重建索引和增量更新
生活随笔
收集整理的這篇文章主要介紹了
Solr定时重建索引和增量更新
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
新增jar包
新增solr-dataimport-scheduler.jar到所有節點tomcat\webapps\下solr項目的WEB-INF\lib下
下載地址:
為Solr配置監聽器
修改所有節點tomcat下的solr的web.xml增加如下配置
<listener> <listener-class> org.apache.solr.handler.dataimport.scheduler.ApplicationListener </listener-class> </listener>
新增配置
在solrhome/conf/中新增名為:dataimport.properties 配置文件
如果是solr-cloud則配置其中1個solrhome/conf需要添加dataimport.properties配置文件
配置內容如下:
#################################################
# #
# dataimport scheduler properties #
# #
################################################## to sync or not to sync
# 1 - active; anything else - inactive
# 這里的配置不用修改
syncEnabled=1# which cores to schedule
# in a multi-core environment you can decide which cores you want syncronized
# leave empty or comment it out if using single-core deployment
# 修改成你所使用的core,我這里是我自定義的core:simple
syncCores=collection1# solr server name or IP address
# [defaults to localhost if empty]
#這個一般都是localhost不會變
server=localhost# solr server port
# [defaults to 80 if empty]
# 安裝solr的tomcat端口,如果你使用的是默認的端口,就不用改了,否則改成自己的端口就好了
port=8180# application name/context
# [defaults to current ServletContextListener's context (app) name]
# 這里默認不改
webapp=solr# URL params [mandatory]
# remainder of URL
# 這里改成下面的形式,solr同步數據時請求的鏈接
params=/dataimport?command=delta-import&clean=false&commit=true# schedule interval
# number of minutes between two runs
# [defaults to 30 if empty]
#這里是設置定時任務的,單位是分鐘,也就是多長時間你檢測一次數據同步,根據項目需求修改
# 開始測試的時候為了方便看到效果,時間可以設置短一點
interval=60# 重做索引的時間間隔,單位分鐘,默認7200,即5天;
# 為空,為0,或者注釋掉:表示永不重做索引
reBuildIndexInterval=7200# 重做索引的參數
#reBuildIndexParams=/select?qt=/dataimport&command=full-import&clean=true&commit=true
reBuildIndexParams=/dataimport?command=full-import&clean=true&commit=true# 重做索引時間間隔的計時開始時間,第一次真正執行的時間=reBuildIndexBeginTime+reBuildIndexInterval*60*1000;
# 兩種格式:2012-04-11 03:10:00 或者 03:10:00,后一種會自動補全日期部分為服務啟動時的日期
reBuildIndexBeginTime=00:00:00
重啟Solr服務
總結
以上是生活随笔為你收集整理的Solr定时重建索引和增量更新的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 堪字开头成语有哪些?
- 下一篇: 2022-2028年中国新能源环卫车行业