Simple Integration of Solr and Mysql

Source: Internet
Author: User
Solr and Mysql integrate Solr with Mysql to create full indexes and incremental indexes. The basic principle is simple: Register Solr DataImportHandler in the solr project and configure the Mysql data source and Data Query SQL statement. Solr calls

Solr and Mysql integrate Solr with Mysql to create full indexes and incremental indexes. The basic principle is simple: Register Solr DataImportHandler in the solr project and configure the Mysql data source and Data Query SQL statement. Solr calls

Simple Integration of Solr and Mysql
The integration of Solr and Mysql Databases allows you to create full and incremental indexes.
The basic principle is simple: Register Solr DataImportHandler in the solr project and configure the Mysql data source and Data Query SQL statement. When we use the Solr background to control the page or directly access an address (provided later), Solr will call DataImportHandler to connect to the database, query data based on SQL statements, and create an index.

Solr version: solr4.3.1
Specify the Solr installation directory, for example, E: \ environment \ solr-4.3.1 is solr-home.


1. Copy the jar package
Copy the jar package of DataImportHandler and the mysql database driver package to the solr-home/dist directory. By default, the directory contains two jar packages required by DataImportHandler. The jar package name for this Solr version is: solr-dataimporthandler-4.3.1.jar, solr-dataimporthandler-extras-4.3.1.jar

2. Modify the solr-home \ example \ solr \ collection1 \ conf \ solrconfig. xml file.
A. Add the required jar package reference Configuration:
 
 


B. Add resultHandler Configuration
       
        
   
    data-config.xml
         
        
 


3. Create a data-config.xml file under the same directory of solrconfig. xml, configure the database connection and the correspondence between Solr and mysql DATA and query statements.
     
       
         
             
              
         
            
                
               
            
        
    
  


4. Restart Solr.
Batch import (full-import ):
Http :// : /Solr/dataimport? Command = full-import & commit = y

Incremental import (delta-import ):
Http :// : /Solr/dataimport? Command = delta-import & commit = y

Import status query (status ):
Http :// : /Solr/dataimport

Reload-config ):
Http :// : /Solr/dataimport? Command = reload-config

Terminate import (abort ):
Http :// : /Solr/dataimport? Command = abort

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.