SQL Server in Solr using Data Import Handler

21 Jul


MS SQL Server connector

Download Microsoft JDBC Driver 4.0 for SQL Server from:

copy file ‘sqljdbc4.jar’ to ‘contrib/dataimporthandler/lib’


copy solrconfig.xml from an existing collection. Find my version of solrconfig.xml below in this gist.

edit solrconfig.xml by adding:

<lib dir="../../contrib/dataimporthandler/lib" regex=".*\.jar" />
<lib dir="../../dist/" regex="solr-dataimporthandler-.*\.jar" />

Make sure that ‘dist’ folder contains two files for data import handler:

  • solr-dataimporthandler-4.10.2.jar
  • solr-dataimporthandler-extras-4.10.2.jar

add these lines to solrconfig.xml:

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">
    <str name="config">data-config.xml</str>

data-config.xml for SQL Server database

  <dataSource type="JdbcDataSource" 
    <entity name="product"  
      query="select id,name from products"
      deltaImportQuery="SELECT id,name from products WHERE id='${}'"
      deltaQuery="SELECT id FROM products  WHERE updated_at > '${dih.last_index_time}'"
       <field column="id" name="id"/>
       <field column="name" name="name"/>       

Copy from:


Leave a comment

Posted by on July 21, 2015 in Application Server, Solr


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: