Solr5.5 index mysql Data (Beginner's summary), solr5.5mysql
Deployment of solr5.5 environment to Eclipse (luna Version)
Solr deployment see: http://blog.csdn.net/csmnjk/article/details/64121765
Set the Ik tokenizer
IK tokenizer settings see: http://blog.csdn.net/csmnjk/article/details/51693578
The schema. xml file of solr4 corresponds to the managed-schema file of solr5, ensuring that http: // localhost: 8080/solr/admin.html is successfully logged on.
3. MySQl Configuration
1. Connecting to the MYSQL database requires two jar packages: solr-dataimporthandler-5.5.0 jar and mysql-connector-java-5.1.40-bin.jar. The first package is in the solr-5.5.0/dist, And the last package is http://download.csdn.net/download/u012453843/9667329.
2. Create a table
Create table 'Article' ('id' int unsigned not null auto_increment comment 'Primary key number', 'title' varchar (64) not null comment 'title ', 'author' varchar (10) not null default 0 comment' author ', 'type' varchar (10) not null default 0 comment' type', primary key ('id ')) engine = innodb auto_increment = 1 default character set = utf8;
3. Configuration File
(1) Add the following configuration under the solrcong. xml file in solrHome \ core \ conf:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler>
And comment out the following code:
<schemaFactory class="ManagedIndexSchemaFactory"> <bool name="mutable">true</bool> <str name="managedSchemaResourceName">managed-schema</str></schemaFactory>
(2) create a data-config.xml file in the conf folder and add the following configuration
<dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/test" user="root" password="password" /> <document name="article"> <entity name="article" pk="id" query="select * from article" deltaImportQuery="select * from article where id ='${dih.delta.id}'" deltaQuery="select id from article where timestamp > '${dih.last_index_time}'"> </entity> </document> </dataConfig>
Description: user: MySQL user name, password: MySQL login password, test: Database Name, article: Table name.
(3) Back up managed-schema elsewhere and rename it schema. xml. Add index Field Configuration
<field name="title" type="text_ik" indexed="true" stored="true" multiValued="true" /> <field name="description" type="text_ik" indexed="true" stored="true" /> <field name="author" type="text_ik" indexed="true" stored="true" />
This configuration is complete!
4. Start solr
Core0-> Dataimport-> full-import-> Execute. Click Refresh Status after execution, and the index information is displayed on the right.
Query Verification:
All four data entries in the table are indexed and queried successfully.