How to setup solr MySQL data importer

Written by: Open Solr Administrator

If you don't feel like creating your own data importer to import data from your SQL database to your SOLR collections, we've also integrated the DIH  - Data Import Handler which now helps you define your SQL connection and query, and import your data to SOLR with just a few clicks.

Here's a demo video on how to edit the SQL connection that will enable you to start importing data to your SOLR collections:

db-data-cofig.xml example:<dataConfig>

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost/dbname" 
              user="user-name" 
              password="password"/>
  <document>
    <entity name="id" 
            query="select id,name,desc from mytable">
    </entity>
  </document>
</dataConfig>
<!--
NOTE !!!
Ensure that your solr schema (schema.xml) has the fields 
'id', 'name', 'desc'. Change the appropriate details in the data-config.xml
-->