【轉】Solr5.3.1定時增量添加索引和重做索引


  本文轉自: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 - 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
syncCores=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 URL
params=/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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM