學習使用solr時遇到的一些問題,記錄

問題1:

一開始我在這個網站實踐http://wiki.apache.org/solr/DIHQuickStart#Index_the_fields_in_different_names

結果到了第五步(Step 5 : Run the command http://solr-host:port/solr/dataimport?command=full-import.)就出現了這樣的錯誤:

HTTP ERROR 404

Problem accessing /solr/dataimport. Reason:

    NOT_FOUND


Powered by Jetty://


其實是因爲之前在啓動solr的時候弄錯了,我之前是用"java -jar start.jar"來啓動的,但是我自己建的文件目錄是這樣的:


在XiaoLongTest裏面有“README.txt”文件,打開它,它會告訴你該怎麼做。另外,當你成功啓動後發現沒有你自己創建的文件怎麼辦:


打開“XiaoLongTest”裏面的solr.xml跟着他的模樣插入一條就好了,依葫蘆畫瓢。然後在啓動一下就有了。


問題2(在data-config.xml裏面配置數據源的問題):

如果你用的sqlserver數據庫,那麼數據源該這樣配置:

<dataSource type="JdbcDataSource" 
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
url="jdbc:sqlserver://localhost:1433;DatabaseName=test" 
user="xx" 
password="xx"/>

如果用的是postgres(大象)數據庫,那麼就這樣配置:

<dataSource name="JdbcDataSource"
driver="org.postgresql.Driver"
       url="jdbc:postgresql://localhost:5433/iclass-dev" (端口號自己看)
       user="xxx"
password="xxx"
/>

驅動包要用複製粘貼的方式方到相應的lib裏面。


問題 3(給sorl設定IK分詞器)  

schema.xml裏面不是有很多的fieldType嗎,其中class爲solr.TextField的類型是可以被分詞器分詞的,我在一個fieldType名字是“text”的類型裏面去設置。ik分詞器需要到網上去下載,那下什麼版本的其實和你的solr版本有關,如果您使用的是Solr1.3或者v2.9之前的Lucene,請下載IK Analyzer3.1.6GA使用! IK Analyzer3.2.X僅支持Lucene3.0以上版本。

   我下載了最新的版本的ik,那怎麼配置到schema.xml裏面呢?其實下載的那個包裏面都有一個pdf是教程,照裏面的做就好了,配置好了後,在把你下載下來的ik的根目錄下面的一個Jar文件,複製到相應文件的Lib下面,就好了。


問題 4(org.apache.solr.common.SolrException: Document [null] missing required field: id) 

<field name="id" type="long" indexed="true" stored="true" required="true" />後面的required去掉。


問題 5(Could not open the editor: Resource is out of sync with the file system)  

我在打開一個文件的時候出現這個錯誤:

當右擊default.properties打開時,出現下圖錯誤:

解決方法:右擊工程,Refresh一下就好了。

原因:Usually happens when some files are edited outside of eclipse。


問題 6(Delta Import Failed)

我在solr裏面進行增量導入的時候,出現了這樣的錯誤:

  

我的data-config.xml裏面的document是這樣寫的:

<document>
		<entity name="Member"  query="select id,fullName,dtype,avatarUrl from Member where isDeleted=false" 
			deltaQuery="select id from Member where lastModifyTime > '${dataimporter.last_index_time}' and isDeleted=false">
			<!-- deltaImportQuery="select id,fullName,dtype,avatarUrl from Member where id = '${dataimporter.delta.id}'"  -->
		</entity>
<document>

現在問題解決了,原因就是沒有在裏面加上 pk="id" (其中這個id是和下面的deltaQuery裏面的字段id一樣)

正確的應該是這樣的:

<document>
		<entity name="Member" pk="id" query="select id,fullName,dtype,avatarUrl from Member where isDeleted=false" 
			deltaQuery="select id from Member where lastModifyTime > '${dataimporter.last_index_time}' and isDeleted=false">
			<!-- deltaImportQuery="select id,fullName,dtype,avatarUrl from Member where id = '${dataimporter.delta.id}'"  -->
		</entity>
<document>


發佈了44 篇原創文章 · 獲贊 12 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章