Resolve issues with SOLR incremental import of MySQL data

Source: Internet
Author: User
Tags solr

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

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.