Today with the SOLR time to rebuild the index and the increment of the new technology, from the Internet search some information, here to everyone to tidy up a bit, also passed their own tests, no abnormalities.
SOLR officially provides a very powerful data Import request Handler, while providing a simple Scheduler, the example Scheduler only supports incremental updates, does not support periodic re-indexing, so I made a simple package, Added a redo index timer.
1. Bring the Apache-solr-dataimportscheduler-1.0.jar and Solr Solr-dataimporthandler-4.7.1.jar, Solr-dataimporthandler-extras-4.7.1.jar is placed under the Webapps/solr/web-inf/lib directory that Tomcat publishes (or under Solr.war's lib directory).
2. Modify the Webapps/solr/web-inf/web.xml released by Tomcat (or modify the Web-inf/web.xml in Solr.war) and add it before the servlet node:
<listener> <listener-class>org.apache.solr.handler.dataimport.scheduler.applicationlistener </listener-class></listener>
3. Remove the dataimport.properties from the Apache-solr-dataimportscheduler-1.0-source.jar and modify it according to the actual situation and place it in the solr.home/conf ( Not solr.home/core/conf) directory below, conf this directory does not exist, you need to manually create the directory yourself.
4. Restart Tomcat or JBoss.
Dataimport.properties Configuration Item Description
################################################## # # DataImport Sched Uler Properties # # ################################################# # # to sync or not to sync# 1-active; Anything else-inactivesyncenabled=1# which cores to schedule# in a multi-core environment can decide which cores y ou want syncronized# leave empty or comment it out if using Single-core deploymentsynccores=core0,core1# SOLR server Nam E or IP address# [defaults to localhost if empty]server=localhost# solr server port# [defaults to + if empty]port=8080 # application name/context# [defaults to current Servletcontextlistener ' s context (APP) name]webapp=solr# URL params [m andatory]# remainder of urlparams=/dataimport?command=delta-import&clean=false&commit=true# schedule interval# number of minutes between-runs# [defaults to If empty]# Delta index interval, unit minutes # is empty, 0, or commented out: Indicates never-incremental index interval=1# the time interval of the redo index, in minutes, by default 7200, i.e. 5 days; # is empty, 0, or commented out: A parameter that never re-indexes rebuildindexinterval=2# indexes rebuildindexparams=/dataimport?command=full-import& clean=false&commit=true# The timing start time of the redo index interval, the first real execution time =rebuildindexbegintime+rebuildindexinterval*60*1000;# Two formats: 2012-04-11 03:10:00 or 03:10:00, the latter one automatically complements the date part as the date when the service was started rebuildindexbegintime=03:10:00
For the above configuration, found two bugs, one is if the value of Rebuildindexbegintime is empty, it will cause the interval strong turn the Times wrong, the other is to request the SOLR server when the status code returned is always 415 (for the current requested method and the requested resource, The entity submitted in the request is not a supported format in the server, so the request is rejected. )
1. First Bug
This piece of code directly causes the method call to report a strong turn error,
This method strongly turns the interval attribute,
See if Rebuildindexbegintime is empty when the code is set:
The above red box is the changed format, the original format only "YYYY-MM-DD" section, this will cause the start of the time will not stop the HTTP request SOLR server, so need to add "HH:mm:ss" to solve the problem.
The first bug resolution is to remove the code from the red box in Figure 1.
2. Second bug
Cause is HTTP with POST request, We know that Dataimport.properties's param is a get-way link, the parameters are also included in the program does not handle the form of the link as a post-submission method, so that the request SOLR failed, the HTTP link to change the way to get on the line.
The original jar package and repackaging of Apache-solr-dataimportscheduler-1.0.jar and Apache-solr-dataimportscheduler-1.0-source.jar mentioned above are in the following address
http://download.csdn.net/detail/ltr15036900300/7209195
SOLR Scheduled Updates