Nadjib Mami
Nadjib Mami

Reputation: 5830

Fully-Importing MySQL database to Solr 4 gives 404 error

Yet another Solr 4 new user. I admired what is Solr able to do in full text searching, but the on-line documentation is a little bit frustrating. Anyway, I'm working on importing my MySQL database (having few millions of records) to Solr.

But when I arrived to perform full importing by interring: http://[localhost]:8983/solr/dataimport?command=full-import I got this error: HTTP ERROR 404 Problem accessing /solr/dataimport. Reason: Not Found. I think this is no more valid in the last version 4. So I tried: http://[localhost]:8983/solr/#/collection1/dataimport?command=full-import but nothing happens.

My fields have been successfully added, I can see them on the admin panel in the schema browser section in collection1.

From the admin -> collection1 -> Dataimport, it show: sorry, no dataimport-handler defined!. Running the start.jar doesn't show errors.

What am I missing right here?

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

Upvotes: 4

Views: 3916

Answers (2)

Tabish
Tabish

Reputation: 1722

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" />

Upvotes: 1

bikedorkseattle
bikedorkseattle

Reputation: 991

You data-config needs to look more like this. You are not specifying a 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 your 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 solr.xml you need to make sure you have the following

<solr persistent="true" sharedLib="../lib">

Upvotes: 3

Related Questions