如何使用Solr数据导入处理程序为MySQL表建立索引? [英] How to use the Solr Data Import Handler to index a MySQL table?

查看:116
本文介绍了如何使用Solr数据导入处理程序为MySQL表建立索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试通过在浏览器中加载它来导入mysql表时:

When I try to import a mysql table by loading this in the browser:

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

我收到此错误:

HTTP ERROR 404

Problem accessing /solr/dataimport. Reason:

    NOT_FOUND

Powered by Jetty://

我正在遵循Solr官方Wiki上的本教程,以开始使用DIH:

I'm following this tutorial from the official Solr wiki to get started with the DIH:

http://wiki.apache.org/solr/DIHQuickStart

根据本教程,我将其添加到了solrconfig.xml:

As per the tutorial I added this to my solrconfig.xml:

<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中,我具有以下内容:

in data-config.xml I have the following:

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost/site" 
              user="root" 
              password="123"/>
  <document>
    <entity name="profiles" 
            query="select user_id,about,music,movies,occupation from profiles">
    </entity>
  </document>
</dataConfig>

这些是我的schema.xml中定义的字段:

And these are the fields defined in my schema.xml:

  <fields>
    <field name="user_id" type="string" indexed="true" stored="true" required="true" />
    <field name="about" type="string" indexed="true" stored="true" />
    <field name="music" type="string" indexed="true" stored="true" />
    <field name="movies" type="string" indexed="true" stored="true" />
    <field name="occupation" type="string" indexed="true" stored="true" />  
    <field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
  </fields>

  <uniqueKey>user_id</uniqueKey>

那么我在做什么错了?我想这可能与data-config.xml文件有关.在其中,我不知道是否假定要使用MySQL驱动程序的某个路径.我从这里下载了MySQL JDBC驱动程序:

So what am I doing wrong? I imagine it may have something to do with the data-config.xml file. In it I don't know if a certain path to the MySQL driver is being assumed. I downloaded the MySQL JDBC driver from here:

http://dev.mysql.com/downloads/connector/j/3.1.html

并将其放在我的/solr/lib目录中.

and put it in my /solr/lib directory.

当我下载驱动程序并将其解压缩时,在一个名为"mysql-connector-java-3.0.17-ga"的文件夹中有许多文件夹.

When I downloaded the driver and extracted it there was a bunch of folders inside one folder called "mysql-connector-java-3.0.17-ga".

我确实注意到里面有一个名为com的目录,而在mysql里面是jbdc里面,还有一个名为Driver.class的文件.

I do notice that inside that there is a dir called: com and inside that mysql and inside that jbdc and inside that there is a file called Driver.class.

这是从data-config.xml中引用的内容吗?如果是这样,为什么不提及初始目录呢?

Is this what is being referenced from data-config.xml? If so why isn't the initial directory not mentioned.

基本上我不知道问题是什么,有人可以帮忙吗.

Basically I have no idea what the issue is, can someone help please.

推荐答案

只需确保在solrconfig.xml文件中包含以下代码行

just make sure you have these lines of code in solrconfig.xml file

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

确保这些jar文件的路径和那些jar文件在该路径上应物理可用.如果没有,请添加它,然后尝试重新启动tomacat服务器,希望它将得到解决.

make sure the path of those jar files and those jar files should be available physically at that path. If you don't have then please add that and try to restart the tomacat server and hopefully it will be resolved.

这篇关于如何使用Solr数据导入处理程序为MySQL表建立索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆