標籤:
本文轉自:https://code.google.com/p/solr-dataimport-scheduler/
Solr Data Import Hander Scheduler 說明:
Solr官方提供了很強大的Data Import Request Handler,同時提供了一個簡單的 Scheduler,Url:http://wiki.apache.org/solr/DataImportHandler
樣本中的 Scheduler 只支援累加式更新,不支援定期重做索引,因此我做了一個簡單的封裝,增加了重做索引的定時器.
(原定時器作者是:Marko Bonaci, 在此表示感謝!)The original Scheduling source by Marko Bonaci, Thank him!
使用說明
將 apache-solr-dataimportscheduler-1.0.jar 和solr內建的 apache-solr-dataimporthandler-.jar, apache-solr-dataimporthandler-extras-.jar 放到solr.war的lib目錄下面
修改solr.war中WEB-INF/web.xml, 在servlet節點前面增加:
<listener> <listener-class> org.apache.solr.handler.dataimport.scheduler.ApplicationListener </listener-class> </listener>
將apache-solr-dataimportscheduler-.jar 中 dataimport.properties 取出並根據實際情況修改,然後放到 solr.home/conf (不是solr.home/core/conf) 目錄下面
重啟tomcat或者jboss 即可
dataimport.properties 配置項說明
################################################## ## dataimport scheduler properties ## ################################################### to sync or not to sync# 1 - active; anything else - inactivesyncEnabled=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 deploymentsyncCores=core1,core2# solr server name or IP address# [defaults to localhost if empty]server=localhost# solr server port# [defaults to 80 if empty]port=8080# application name/context# [defaults to current ServletContextListener‘s context (app) name]webapp=solr# URL params [mandatory]# remainder of URLparams=/dataimport?command=delta-import&clean=false&commit=true# schedule interval# number of minutes between two runs# [defaults to 30 if empty]interval=1# 重做索引的時間間隔,單位分鐘,預設7200,即5天; # 為空白,為0,或者注釋掉:表示永不重做索引reBuildIndexInterval=7200# 重做索引的參數reBuildIndexParams=/dataimport?command=full-import&clean=true&commit=true# 重做索引時間間隔的計時開始時間,第一次真正執行的時間=reBuildIndexBeginTime+reBuildIndexInterval*60*1000;# 兩種格式:2012-04-11 03:10:00 或者 03:10:00,後一種會自動補全日期部分為服務啟動時的日期reBuildIndexBeginTime=03:10:00
【轉】Solr5.3.1定時增量添加索引和重做索引