简体   繁体   中英

apache solr does not load mysql data into core

i'm using apache solr version 6.4.1 on windows 10 .i want to load data from mysql database into solr core but it does not works. here is the scenario : there is a core named ako in directory \\solr-6.4.1\\solr-6.4.1\\server\\solr and files solrconfig.xml & db-data-config.xml in directory \\solr-6.4.1\\solr-6.4.1\\server\\solr\\ako\\conf . i added needed lines of code to solrconfig.xml as below :

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

<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-6.4.1.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-extras-6.4.1.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/extraction/lib" regex=".*\.jar" />

and below is content of file db-data-config.xml :

<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/meeva" user="root" password=""/>
    <document>
    <entity name="businesses" query="select id, title from businesses">
        <field column="id" name="biz_id" />
        <field column="title" name="biz_title" />
    </entity>
</document>
</dataConfig>

i added scema.xml file with this below content , but still does not work:

<field name="biz_id" type="int" indexed="true" stored="true" required="true" multiValued="false" />

<field name="biz_title" type="string" indexed="true" stored="true"/>

but when importing data from solr admin page ( go to http://localhost:8983/solr/#/ako/dataimport//dataimport?command=full-import ) it returns Requests: 0 , Fetched: 0 , Skipped: 0 , Processed: 0 and nothing is added to core.can anyone help please?

It is not enough to have solr-dataimporter handler enabled. You need to enable mysql-connector as well. Go to mysql archives: https://downloads.mysql.com/archives/cj/ Choose version close to date release of your Solr version. Download it, and copy .jar file, eg mysql-connector-java-5.1.41-bin.jar to your solr libs directory (probably, this is /dist directory under your solr installation path).

You got to restart Solr service to apply this.

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