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