简体   繁体   English

使用solr搜索mysql数据库表

[英]Using solr search for mysql database table

I am new to solr and trying to use it to index my database "zend" and table "users". 我是solr的新手,并尝试使用它为我的数据库“ zend”和表“ users”建立索引。 Below is the code of data-config.xml that is located at /solr/example/solr/conf/ folder 以下是/ solr / example / solr / conf /文件夹中的data-config.xml代码

<dataConfig>
    <dataSource type="JdbcDataSource" 
              driver="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost/zend" 
              user="root" 
              password=""/>
    <document>
        <entity name="id" query="select id,first_name,last_name from users">
            <field column="id" name="solr_id"/>
            <field column="first_name" name="solr_first_name"/>
            <field column="last_name" name="solr_last_name"/>
        </entity>
    </document>
</dataConfig>

Below code I put in solrconfig.xml located at /solr/example/solr/conf folder 下面的代码我放在位于/ solr / example / solr / conf文件夹中的solrconfig.xml中

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

And these fields I added in schema.xml of /solr/example/solr/conf folder 这些字段是我在/ solr / example / solr / conf文件夹的schema.xml中添加的

<field name="solr_id" type="genericID" indexed="true" stored="true"/>
<field name="solr_first_name" type="textgen" indexed="true" stored="true"/>
<field name="solr_last_name" type="textgen" indexed="true" stored="true"/>

After making these changes I run java -jar start.jar 进行这些更改后,我运行java -jar start.jar

When I hit the full import command from browser like 当我从浏览器点击完整的导入命令时

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

Then I get the error: 然后我得到错误:

HTTP ERROR: 500 HTTP错误:500
Severe errors in solr configuration. solr配置中存在严重错误。
Check your log files for more detailed information on what may be wrong. 检查您的日志文件以获取有关可能出问题的更多详细信息。
If you want solr to continue after configuration errors, change: 如果您希望solr在配置错误后继续运行,请更改:
<abortOnConfigurationError>false</abortOnConfigurationError> <abortOnConfigurationError>假</ abortOnConfigurationError>
in null 无效

Please advise. 请指教。

You have an configuration error at your config - files. 您的config-文件中存在配置错误。 That could be for example an syntax error, missing end-tag or something like that. 例如,这可能是语法错误,缺少结束标记或类似的东西。 Your solution is written at your question: 您的解决方案写在您的问题上:

Check your log files for more detailed information on what may be wrong.

So please check the output of your java-container.... probably the output of the java -jar command or the logfiles generated by java and/or the start.jar ..and post the output here 因此,请检查您的java-container的输出...。可能是java -jar命令的输出或java和/或start.jar ..生成的日志文件,然后将输出发布到此处

Witch version of Solr are you using? 您正在使用女巫版本的Solr吗? In never versions DIH is not in solr.war, but have to be loaded externally: SOLR-2365: DIH should not be in the Solr war 在从不版本中,DIH不在solr.war中,而必须从外部加载: SOLR-2365:DIH不应在Solr战争中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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