SOLR Import Database Data

Source: Internet
Author: User
Tags solr import database

Connect Solr-4.10.2 with Tomcat integration.
1.Add the Data Import node to the Solrconfig.xml, and the Solrconfig.xml path is D:\solr\data\solr\collection1\conf\solrconfig.xml.
<requesthandler name= "/dataimport" class= "Org.apache.solr.handler.dataimport.DataImportHandler" >
<lst name= "Defaults" >
<str name= "config" >data-config.xml</str>
</lst>
</requestHandler>
2.Create a new data-config.xml in the D:\solr\data\solr\collection1\conf directory with the following content:
<dataConfig>
<datasource type= "Jdbcdatasource"
driver= "Com.mysql.jdbc.Driver"
url= "Jdbc:mysql://192.98.12.55:3306/test"
user= "Root"
password= "root"/>
<document>
<entity name= "solr_test" transformer= "Dateformattransformer "
query= "Select f_id, F_content, f_note_time from Note_info" >
<field column= ' f_id ' name= ' id '/>
<field column= ' f_note_time ' datetimeformat= ' yyyy-mm-dd HH:mm:ss '/>
<field column= ' f_content ' name= ' f_content '/>
</entity>
</document>
</dataConfig>
3.Copy D:\solr\solr-4.10.2\ Solr-dataimporthandler-4.10.2.jar and Solr-dataimporthandler-extras-4.10.2.jar to Tomcat\webapps\solr\web-inf in the Dist directory The \lib directory. and the corresponding database-driven jar.
4.The modified Schema.xml,schema.xml is located in D:\solr\data\solr\collection1\conf\. Add the following nodes
<field name= "F_note_time" type= "date" stored= "true"/>
<field name= "f_content" type= "Text_general" indexed= "true" stored= "true"/>
5.Login Solradmin Import data


Parameter description: The clean option refers to whether to delete data that does not match. That is, not in the database select result, but the SOLR Index library exists, then delete.
6 . View Imported Data

If you do not see the imported data, you can view the troubleshooting.

SOLR Import Database Data

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.