Step one: Insert a new RequestHandler in Solrconfig.xml and add the following lines
<requesthandler name= "/dataimportcommentdelta" class= "Org.apache.solr.handler.dataimport.DataImportHandler" > <lst name= "Defaults" > <str name= "config" >data-config-comment-delta.xml</str> </lst> </requestHandler>
Step Two: Write Data-config-comment-delta.xml, write the following, note the conditions in query, Dih.last_index_time, indicates the time that SOLR last indexed. The Full-import that SOLR performs this configuration is actually equivalent to incrementally importing data
<dataconfig> <datasource type= "Jdbcdatasource" driver= "Com.mysql.jdbc.Driver" url= "JDBC:MYSQL://LOCALHOST/MOOC" user= "Root" password= "Root"/> <document> <entity name= "comment" Query= "Select id, date_format (writetime, '%y-%m-%dt%tz ') as ' writetime ', title from comment where date (updatetime) > ' ${dih.last_index_time} ' OR DATE (writetime) > ' ${dih.last_index_time} ' > <field column= "id" name= "id"/> <field column= "Writetime" name= "Writetime"/> <field column= "title" name= "title"/> </entity> </document></dataConfig>
Resolve issues with SOLR incremental import of MySQL data