2011-12-21 139 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