简体   繁体   中英

How to import data from mysql to solr

I am trying to do the full db import using below URL

    `127.0.0.1:8983/solr/dataimport?command=full-import`

I installed solr and trying to configure it. I changed few files and putted details (file names and added code is described below). But when I am trying to import the table data into solr json format it is showing below error:

    HTTP ERROR 404

    Problem accessing /solr/dataimport. Reason:

    Not Found
        Powered by Jetty://

Can anyone let me know what the actual problem is? Or did I misconfigure Sorl?


My data-config.xml file have below code:

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost/sq_dbLoveOffers" 
              user="pksqueak" 
              password="passwd"/>
  <document>
    <entity name="id" 
            query="select sq_prom_id, sq_prom_name, sq_prom_description, sq_latitude, sq_longitude from sq_offers">
    </entity>
  </document>
</dataConfig>

I added below code into Solrconfig.xml:

<lib dir="../../../../contrib/dataimporthandler/lib/" regex=".*\.jar" />
<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>

I added below code in schema.xmal FILE:

<fields>
    <field name="sq_prom_id" type="string" indexed="true" stored="true" required="true" />
    <field name="sq_prom_name" type="string" indexed="true" stored="true" />
    <field name="sq_prom_description" type="string" indexed="true" stored="true" />
    <field name="sq_latitude" type="string" indexed="true" stored="true" />
    <field name="sq_longitude" type="string" indexed="true" stored="true" />
</fields>

In case the core you address is not your default core, your request is lacking the core's name in the URL. You should request should be like this

127.0.0.1:8983/solr/<core-name>/dataimport?command=full-import

There you need to replace the <core-name> with the actual name of your core, as configured in your solr.xml.

I used below command to run sorl server for DIH.

java -Dsolr.solr.home="./example-DIH/solr/" -jar start.jar

and I did the full import using below URL, it solved my problem.

http://127.0.0.1:8983/solr/db/dataimport?command=full-import

我有一个运行正常的数据导入处理程序,如有必要,您可以与我比较配置http://amac4.blogspot.co.uk/2013/08/configuring-solr-4-data-import-handler.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM