Index a DB table directly into Solr

2019-04-16 15:59发布

问题:

I want to import data from database directly into the solr index. I found this tutorial very helpful.

However I have a problem to get this to work. I first set up a requestHandler like this

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

data-config.xml:

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost/admin_pproject" 
              user="root" 
              password=""/>
  <document>
    <entity name="id" 
            query="select id from admin_pproject">
    </entity>
  </document>
</dataConfig>

When I run full import I get several errors:

Any ideas?

回答1:

Try adding the full path to data-config.xml in solrconfig. Also, check what happens if you try to access http://localhost:8983/solr/admin/dataimport.jsp?handler=/dataimport from a browser.

If you still have problems, then please post the Jetty logs generated while starting Solr - they might provide clues.



标签: solr