Solr4.9 synchronize mysql Data
Solr is a high-performance full-text search server developed by Java 5 based on Lucene. At the same time, it is expanded to provide a richer query language than Lucene, and at the same time, it is configurable and scalable, and the query performance is optimized, it also provides a complete functional management interface and is a very good full-text search engine.
Data in the database can be imported into solr, and millions of data can be quickly responded to the query.
1. Install jdk
JDK version 1.7 or later
2. Install solr
Download the solr compressed package, decompress the installation package, go to the SOLR_HOME \ example directory, and run the java-jar start. jar command to start solr
Solr uses the default port 8983 to access http: // localhost: 8983/solr. If the following interface exists, the server is successfully started.
3. Import and update data configuration
Solr provides the ability to import database data to the solr index database (dataimport)
3.1 download the database driver package
Download the mysql driver package and put it in the {% SOLR_HOME %} contrib \ dataimporthandler \ lib directory
3.2 configure solrconfig. xml3.2.1 and reference related libraries
Solrconfig. xml contains the vast majority of parameters used to configure its own behavior. Its scope is the current core. The file is located in the file directory {% solr_home %} example \ solr \ collection1 \ conf.
To import data, you must reference the mysql driver package and the package required by DataImport.
Add the following content to the file:
3.2.2 configure requestHandler
Add the following configuration to solrconfig. xml:
Data-config.xml
3.3 configure schema. xml
Schema. xml allows you to flexibly configure different types of fields at the same location as solrconfig. xml.
To import data, you must configure the same type as the fields in the database. In the configuration file
3.3 configure the data source
In the same directory as solrconfig. xml ({% solr_home %} example \ solr \ collection1 \ con), create a data-config.xml for the Data configuration file with the same name as in configuration 3.2.2,
And add the following content:
Driver = "com. mysql. jdbc. Driver"
Url = "jdbc: mysql: // localhost/exercise"
User = "root"
Password = ""
BatchSize = "-1"/>
4. Import Data
Access solr Interface
Select "full-import" for "Command", "Entity" for "table to be imported", and click "Execute" to import data.
After the index is created, a prompt is displayed.
Then, you can enter related Query conditions on the Query interface for Query.