2011-12-21 130 views
1

我是新来solr并试图用它来索引我的数据库“zend”和表“用户”。下面是位于/ solr的/示例/ solr的/ CONF /文件夹使用solr搜索mysql数据库表

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

下面代码我把在位于/ solr的/示例solrconfig.xml中/ solr的/ conf文件夹中的数据-config.xml中的代码我在/ Solr的/例子/ Solr的/ conf文件夹

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

的schema.xml中添加

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

而这些领域做了这些改变后,我跑java -jar start.jar

当我从浏览器中点击全面导入命令一样

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

然后我得到的错误:

HTTP ERROR: 500
Severe errors in solr configuration.
Check your log files for more detailed information on what may be wrong.
If you want solr to continue after configuration errors, change:
<abortOnConfigurationError>false</abortOnConfigurationError>
in null

请指教。

+0

接受的答案,帮助,并开始建立自己的声誉和评价 – 2011-12-21 21:05:49

回答

0

你的配置文件有配置错误。 这可能是一个例如语法错误,缺少结束标签或类似的东西。

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

所以,请检查你的Java容器的输出.... -jar命令的java可能是输出或通过Java和/或开始生成日志文件: 您的解决方案是你的问题写.jar ..并在此输出

+0

我能够索引的数据,但现在的问题是没有结果来了在搜索任何东西之后。我正在使用http://code.google.com/p/solr-php-client/wiki/ExampleUsage中介绍的方式。请咨询 – neeraj 2011-12-21 10:57:23

+0

首先您应该检查,如果您的solr运行正常。为此,请使用'http:// localhost:8983/solr/admin'。如果所有文档都被编入索引并在'http:// localhost:8983/solr/admin'上搜索'http:// phoenixdb01t:8080/solr/rss/admin/stats.jsp'' – 2011-12-21 12:02:56

+0

问题是,solr正在比较作为我在搜索中提供的确切词匹配的关键。但是,当我从“textgen”更改类型“文本”,然后它开始像mysql中的“LIKE”运算符一样搜索。所以现在这个问题已经解决了。非常感谢您的建议。 – neeraj 2011-12-21 12:29:15

0

女巫版本的Solr是否在使用?在从未版本谛是不是在solr.war,但在外部加载:SOLR-2365: DIH should not be in the Solr war

+0

此问题已被解决(上周)。搜索结果即将到来。之前的solr搜索确切的单词,无论我提供的是什么,但是在将schema.xml中的类型更改为“text”之后,它开始正常工作。无论如何感谢您的关心。顺便说一句,我使用SOLR 1.4.1 – neeraj 2011-12-27 06:57:12