solr建立pdf/word/excel索引的方法


  

PS: 本文假設你已經成功的搭建了一個Solr服務器
步驟如下:
(1)准備好一份Solr的源碼,假設現在保存在c:\apache-solr-1.4.1\目錄下
(2)從https://issues.apache.org/jira/browse/SOLR-284 上下載最新的rich.patch, libs.zip和test-files.zip三個文件
(3)解壓libs.zip到c:\apache-solr-1.4.1\lib目錄下,里面的jar就是負責分析Pdf、word和excel的
(4)新建一個文件patch-build.xml,內容如下:

Xml代碼   收藏代碼
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <project name="solr-patch" default="apply-patch" basedir=".">  
  3.     <target name="apply-patch" description="Apply a patch file. Set -      Dpatch.file">  
  4.         <patch patchfile="${patch.file}" strip="0" />  
  5.     </target>  
  6. </project>  

 
(5) 將rich.patch復制到c:\apache-solr-1.4.1\目錄下,運行ant -Dpatch.file=rich.patch -f patch-build.xml 給solr打補丁,注意這里需要ant和Cygwin兩個運行環境!
(6)執行ant dist 重新編譯Solr包,編譯好的文件在dist目錄下將它復制到tomcat里面
(7)打開solrconfig.xml,添加如下內容:

Xml代碼   收藏代碼
  1. <requestHandler name="/update/rich" class="solr.RichDocumentRequestHandler" startup="lazy">  
  2. </requestHandler>  

 然后將 
  

Xml代碼   收藏代碼
  1. <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />  

         
 的enableRemoteStreaming屬性設為true

(8)解壓test-files.zip 到任意目錄,假設現在是在c:\apache-solr-1.4.1\test\ 目錄下
(9)啟動SOLR,在瀏覽器輸入:
http://localhost:8983/solr/update/rich?stream.type=doc&stream.file=c:/apache-solr-1.4.1/test/test-files/complex.doc&fieldnames=id&id=101&stream.fieldname=name&commit=true
為complex.doc 文件建立索引

(10) 打開http://localhost:8983/solr/admin/form.jsp 頁輸入關鍵字測試索引,完成!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM