Solr6.5 and MySQL integration indexing

Source: Internet
Author: User
Tags solr


First in Solrconfig.xml (mine is saved under/usr/local/tomcat/solrhome/mycore/conf/) the <requesthandler name= "/select" class= "SOLR. Searchhandler "> Added above

(I have this/dtatimport in my local solrconfig.xml just change the class to the following)
<requesthandler name= "/dataimport" class= "Org.apache.solr.handler.dataimport.DataImportHandler" >     <lst name= "Defaults" >        <str name= "config" >data-config.xml</str>     </lst>     

Then the Solr-data-config.xml file in the Conf. The contents are as follows:


<dataconfig> <datasource name= "Source1" type= "Jdbcdatasource" driver= " Com.mysql.jdbc.Driver "Url=" Jdbc:mysql://localhost:3306/user (database name) "user=" root "password=" root "batchsize="-1 "/ > <document> <entity name= "News" pk= "id" datasource= "source1" query= "SELECT * Fro M News "deltaimportquery=" SELECT * from news where id= ' ${dih.delta.id} ' "deltaquery=" se Lect ID from news where updatetime> ' ${dataimporter.last_index_time} ' "> <field column=" id "name=" id "/> < Field column= "title" Name= "title"/> <field column= "Synopsis" name= "Synopsis"/> <field column= "UpdateTime "Name=" UpdateTime "/> </entity> </document> </dataConfig> 

DataSource is a database data source. An entity is a table of entities, and PK is the primary key, and query is the queried statement. Fields correspond to a field, column is the column name in the database, and the Name property follows the name of SOLR's filed. Where user is the database name, news is the table name.
Where Deltaquery is an incremental index, the principle is to query the ID number of all data that needs to be incrementally imported from the database according to the SQL statement specified by Deltaquery. The data for all these IDs is then returned based on the SQL statement specified by Deltaimportquery, which is the data to be processed for this increment. The core idea is to log the ID of the secondary index and the time of the last index by using the built-in variables "${dih.delta.id}" and "${dataimporter.last_index_time}".

Then put the required jar package for MySQL (to download the corresponding jar package) and solr-6.2.0\ The Solr-dataimporthandler-6.2.0.jar and Solr-dataimporthandler-extras-6.2.0.jar under Dist are copied to the project Web-inf\lib ( This step was made when SOLR was installed)

Start Tomcat, enter http://localhost:8080/solr/index.html as follows,





Solr6.5 and MySQL integration indexing

Related Article

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.