SOLR data import request handler Scheduler

Source: Internet
Author: User
Tags solr

Reprinted from: http://www.cnblogs.com/ezhangliang/archive/2012/04/11/2441945.html

Scheduler mainly solves two problems:

1. Update indexes on a regular basis.

2. Redo the index regularly.

After testing, scheduler has been able to implement completely configuration-based, without the need for development features, without manual intervention to implement the above two features (combined with SOLR data import request handler ).

To facilitate later use, I put the code on the http://code.google.com with the address: http://code.google.com/p/solr-dataimport-scheduler/

Here we will post the main code memo:

Solrdataimportproperties. Java Configuration File Read:

View code

Basetimertask. Java timertask base class encapsulates some basic attribute reading and request sending methods:

View code

Deltaimporthttppostscheduler. Java incremental Index Update task plan:

View code

Fullimporthttppostsched. Java redo index task plan:

View code

Applicationlistener. Java:

View code

 

Instructions for use
1. package the above compilation file into a apache-solr-dataimportscheduler-1.0.jar, and then bring APACHE-SOLR-dataimporthandler-* with SOLR -*. jar, APACHE-SOLR-dataimporthandler-extras -*. jar to SOLR. under the lib directory of war
2. Modify WEB-INF/Web. XML in SOLR. War and add the following before the servlet node:

<listener> <listener-class> org.apache.solr.handler.dataimport.scheduler.ApplicationListener </listener-class> </listener>

3. run APACHE-SOLR-dataimportscheduler -. dataimport. properties is retrieved and modified according to the actual situation, and then placed in SOLR. home/conf (not SOLR. home/CORE/conf) Directory
4. Restart tomcat or JBoss.

Dataimport. properties configuration item description

######################################## ########### Dataimport schedort 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 = C Ore1, 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 # interval of redoing Indexes, the Unit is minute. The default value is 7200, that is, 5 days. # If it is null, It is 0, or comment out: rebuildindexinterval = 7200 # rebuildindexparams =/dataimport? Command = Full-Import & clean = true & commit = true # timing start time of the redo index interval. The time for the first real execution = rebuildindexbegintime + rebuildindexinterval * 60*1000; # Two formats: 03:10:00 or 03:10:00. The latter will automatically complete the date part of the rebuildindexbegintime = 03:10:00

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.