Complete MySQL database import in Solr 4 gives 404 errors

Another new user to Solr 4. I admired what Solr can do in full-text search, but the online documentation is a little frustrating. Anyway, I'm working on importing my MySQL database (with several million records) into Solr.

  • I downloaded the Java connector and saved it in the example/lib directory.
  • I created data-config.xml and put in it:

     <document name="doc"> <entity name="pagey" query="SELECT * FROM page"> <field column="id" name="pid" /> <field column="Content" name="pcontent" /> <field column="bid" name="bid" /> <field column="Num" name="num" /> </entity> </document> 

    and saved it in: /example/solr/collection1/conf .

  • Associated this file with solrconfig.xml , adding:

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

  • Modified schema.xml to add my new fields.

But when I came to complete the full import via interring: http://[localhost]:8983/solr/dataimport?command=full-import , I got this error: HTTP ERROR 404 Problem accessing /solr/dataimport. Reason: Not Found HTTP ERROR 404 Problem accessing /solr/dataimport. Reason: Not Found . I think this is not more relevant in the latest version 4. Therefore, I tried: http://[localhost]:8983/solr/#/collection1/dataimport?command=full-import , but nothing happens.

My fields have been successfully added, I see them in the admin panel in the browser section of the scheme in collection1.

From admin โ†’ collection1 โ†’ Dataimport, it shows: sorry, no dataimport-handler defined! . Running start.jar does not show errors.

What am I missing right here?

EDIT:. After solving it, remember that "XML is case sensitive."

+4
source share
2 answers

You need to configure data-config. You do not specify the mysql host, user or password.

 <dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:8889/yourdatabase" user="mysql_user" password="mysql_password"/> <document name="doc"> <entity name="pagey" query="SELECT * FROM page"> <field column="id" name="pid" /> <field column="Content" name="pcontent" /> <field column="bid" name="bid" /> <field column="Num" name="num" /> </entity> </document> </dataConfig> 

You need to include this in the solrconfig.xml file.

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

and

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

In the solr.xml file, you need to make sure that you have the following

 <solr persistent="true" sharedLib="../lib"> 
+3
source
 If you are using latest Solr then use <lib dir="../../../dist/" regex="solr-dataimporthandler-\d.*\.jar" /> instead of <lib dir="../../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" /> 
+1
source

All Articles