solrconfig.xml配置的示例分析

小編給大家分享一下solrconfig.xml配置的示例分析,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

成都創(chuàng)新互聯(lián)公司主營(yíng)長(zhǎng)葛網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app軟件開發(fā),長(zhǎng)葛h5小程序開發(fā)搭建,長(zhǎng)葛網(wǎng)站營(yíng)銷推廣歡迎長(zhǎng)葛等地區(qū)企業(yè)咨詢

solrconfig.xml配置文件主要定義了SOLR的一些處理規(guī)則,包括索引數(shù)據(jù)的存放位置,更新,刪除,查詢的一些規(guī)則配置。

      可以在tomcat的安裝路徑下找到這個(gè)文件C:\Program Files\Apache Software Foundation\Tomcat 8.0\solr\collection1\conf

       1.datadir節(jié)點(diǎn)

         1.<dataDir>${solr.data.dir:d:/Server/Solr/data}</dataDir>定義了索引數(shù)據(jù)和日志文件的存放位置      

     2.luceneMatchVersion

             <luceneMatchVersion>4.8</luceneMatchVersion>

          表示solr底層使用的是lucene4.8

      3. lib

            <lib dir="../../../contrib/extraction/lib"regex=".*\.jar"/>

         表示solr引用包的位置,當(dāng)dir對(duì)應(yīng)的目錄不存在時(shí)候,會(huì)忽略此屬性

      4.directoryFactory

          索引存儲(chǔ)方案,共有以下存儲(chǔ)方案

           1、solr.StandardDirectoryFactory,這是一個(gè)基于文件系統(tǒng)存儲(chǔ)目錄的工廠,它會(huì)試圖選擇最好的實(shí)現(xiàn)基于你當(dāng)前的操作系統(tǒng)和Java虛擬機(jī)版本。
           2、solr.SimpleFSDirectoryFactory,適用于小型應(yīng)用程序,不支持大數(shù)據(jù)和多線程。
           3、solr.NIOFSDirectoryFactory,適用于多線程環(huán)境,但是不適用在windows平臺(tái)(很慢),是因?yàn)镴VM還存在bug。
           4、solr.MMapDirectoryFactory,這個(gè)是solr3.1到4.0版本在linux64位系統(tǒng)下默認(rèn)的實(shí)現(xiàn)。它是通過使用虛擬內(nèi)存和內(nèi)核特性調(diào)用

             mmap去訪問存儲(chǔ)在磁盤中的索引文件。它允許lucene或solr直接訪問I/O緩存。如果不需要近實(shí)時(shí)搜索功能,使用此工廠是個(gè)不錯(cuò)的方案。
           5、solr.NRTCachingDirectoryFactory,此工廠設(shè)計(jì)目的是存儲(chǔ)部分索引在內(nèi)存中,從而加快了近實(shí)時(shí)搜索的速度。
           6、solr.RAMDirectoryFactory,這是一個(gè)內(nèi)存存儲(chǔ)方案,不能持久化存儲(chǔ),在系統(tǒng)重啟或服務(wù)器crash時(shí)數(shù)據(jù)會(huì)丟失。且不支持索引復(fù)制

<directoryFactory class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}" name="DirectoryFactory">
   <str name="solr.hdfs.home">${solr.hdfs.home:}</str>
   <str name="solr.hdfs.confdir">${solr.hdfs.confdir:}</str>
   <str name="solr.hdfs.blockcache.enabled">${solr.hdfs.blockcache.enabled:true}</str>
   <str name="solr.hdfs.blockcache.global">${solr.hdfs.blockcache.global:true}</str>
</directoryFactory>

             5. codecFactory
                   編解碼工廠允許使用自定義的編解碼器。例如:如果想啟動(dòng)per-field DocValues格式, 可以在solrconfig.xml里面設(shè)置SchemaCodecFactory:
                    docValuesFormat="Lucene42": 這是默認(rèn)設(shè)置,所有數(shù)據(jù)會(huì)被加載到堆內(nèi)存中。
          docValuesFormat="Disk": 這是另外一個(gè)實(shí)現(xiàn),將部分?jǐn)?shù)據(jù)存儲(chǔ)在磁盤上。
          docValuesFormat="SimpleText": 文本格式,非常慢,用于學(xué)習(xí)。

                  <codecFactory class="solr.SchemaCodecFactory"/>
                  <schemaFactory class="ClassicIndexSchemaFactory"/>

            6.indexconfig節(jié)點(diǎn)

                 用于設(shè)置索引的低級(jí)別的屬性

      1、<filter class="solr.LimitTokenCountFilterFactory" maxTokenCount="10000"/>//限制token最大長(zhǎng)度
      2、<writeLockTimeout>1000</writeLockTimeout>//IndexWriter等待解鎖的最長(zhǎng)時(shí)間(毫秒)。
      3、<maxIndexingThreads>8</maxIndexingThreads>//
      4、<useCompoundFile>false</useCompoundFile>//solr默認(rèn)為false。如果為true,索引文件減少,檢索性能降低,追求平衡。
      5、<ramBufferSizeMB>100</ramBufferSizeMB>//緩存
      6、<maxBufferedDocs>1000</maxBufferedDocs>//同上。兩個(gè)同時(shí)定義時(shí)命中較低的那個(gè)。
      7、<mergePolicy class="org.apache.lucene.index.TieredMergePolicy">
         <int name="maxMergeAtOnce">10</int>
          <int name="segmentsPerTier">10</int>
         </mergePolicy>
          //合并策略。
      8、<mergeFactor>10</mergeFactor>//合并因子,每次合并多少個(gè)segments。
      9、<mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler"/>//合并調(diào)度器。
     10、<lockType>${solr.lock.type:native}</lockType>//鎖工廠。
     11、<unlockOnStartup>false</unlockOnStartup>//是否啟動(dòng)時(shí)先解鎖。
     12、<termIndexInterval>128</termIndexInterval>//Lucene loads terms into memory 間隔
     13、<reopenReaders>true</reopenReaders>//重新打開,替代先關(guān)閉-再打開。
     14、<deletionPolicy class="solr.SolrDeletionPolicy">//提交刪除策略,必須實(shí)現(xiàn)org.apache.lucene.index.IndexDeletionPolicy
     15、<str name="maxCommitsToKeep">1</str>
     16、<str name="maxOptimizedCommitsToKeep">0</str>
     17、<str name="maxCommitAge">30MINUTES</str> OR <str name="maxCommitAge">1DAY</str><br> 

     18、   <infoStream   file="INFOSTREAM.txt">false</infoStream>//相當(dāng)于把創(chuàng)建索引時(shí)的日志輸出。

      <lockType>${solr.lock.type:native}</lockType>
       設(shè)置索引庫的鎖方式,主要有三種:
        1.single:適用于只讀的索引庫,即索引庫是定死的,不會(huì)再更改
        2.native:使用本地操作系統(tǒng)的文件鎖方式,不能用于多個(gè)solr服務(wù)共用同一個(gè)索引庫。Solr3.6 及后期版本使用的默認(rèn)鎖機(jī)制。
        3.simple:使用簡(jiǎn)單的文件鎖機(jī)制

    7. updateHandler節(jié)點(diǎn)

           定義更新處理器,

<updateLog>  
 <str name="dir">${solr.ulog.dir:}</str>  
 </updateLog>

                設(shè)置索引庫更新日志,默認(rèn)路徑為solr home下面的data/tlog。隨著索引庫的頻繁更新,tlog文件會(huì)越來越大,

        所以建議提交索引時(shí)采用硬提交方式<autoCommit>,即批量提交。       

<autoCommit>  
 <maxTime>15000</maxTime>  
 <maxDocs>10000</maxDocs>  
 <openSearcher>false</openSearcher>  
 </autoCommit>

          自動(dòng)硬提交方式:maxTime:設(shè)置多長(zhǎng)時(shí)間提交一次maxDocs:設(shè)置達(dá)到多少文檔提交一次openSearcher:文檔提交后是否開啟新的searcher,

          如果false,文檔只是提交到index索引庫,搜索結(jié)果中搜不到此次提交的文檔;如果true,既提交到index索引庫,也能在搜索結(jié)果中搜到此次提交的內(nèi)容。

<updateHandler class="solr.DirectUpdateHandler2">
    <!-- 允許事務(wù)日志  --> 
    <updateLog>
      <str name="dir">${solr.ulog.dir:}</str>
    </updateLog>

    <!-- 
   在滿足一定條件時(shí)自動(dòng)提交。maxDocs/maxTime/openSearcher
      -->
     <autoCommit> 
       <maxTime>15000</maxTime> 
       <openSearcher>false</openSearcher> 
     </autoCommit>

    <!-- 軟提交VS硬提交 -->
     <!--
      <autoSoftCommit> 
         <maxTime>1000</maxTime> 
       </autoSoftCommit>
      -->

    <!-- 
       更新相關(guān)事件監(jiān)聽器
        postCommit - fired after every commit or optimize command
         postOptimize - fired after every optimize command
      -->
    <!-- The RunExecutableListener executes an external command from a
         hook such as postCommit or postOptimize.
         exe - the name of the executable to run
         dir - dir to use as the current working directory. (default=".")
         wait - the calling thread waits until the executable returns. 
                (default="true")
         args - the arguments to pass to the program.  (default is none)
         env - environment variables to set.  (default is none)
      -->
    <!--
      <listener event="postCommit" class="solr.RunExecutableListener">
         <str name="exe">solr/bin/snapshooter</str>
         <str name="dir">.</str>
         <bool name="wait">true</bool>
         <arr name="args"> <str>arg1</str> <str>arg2</str> </arr>
         <arr name="env"> <str>MYVAR=val1</str> </arr>
       </listener>
      -->
exe--可執(zhí)行的文件類型   
dir--可以用該目錄做為當(dāng)前的工作目錄。默認(rèn)為"."   
wait--調(diào)用線程要等到可執(zhí)行的返回值   
args--傳遞給程序的參數(shù) 默認(rèn)nothing   
env--環(huán)境變量的設(shè)置 默認(rèn)nothing 
 </updateHandler>

                 8.Query查詢節(jié)點(diǎn)

             <maxBooleanClauses>1024</maxBooleanClauses>
             設(shè)置boolean 查詢中,最大條件數(shù)。在范圍搜索或者前綴搜索時(shí),會(huì)產(chǎn)生大量的 boolean 條件,
             如果條件數(shù)達(dá)到這個(gè)數(shù)值時(shí),將拋出異常,限制這個(gè)條件數(shù),可以防止條件過多查詢等待時(shí)間過長(zhǎng)。
                             緩存方法http://www.cnblogs.com/phinecos/archive/2012/05/24/2517018.html

<filterCache class="solr.FastLRUCache" size="512" initialSize="512" autowarmCount="0"/>

<queryResultCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0"/>

<documentCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0"/>

<queryResultMaxDocsCached>200</queryResultMaxDocsCached>

<maxWarmingSearchers>2</maxWarmingSearchers>


                9.Request Dispatcher

                        請(qǐng)求轉(zhuǎn)發(fā)器

<!-- Request Dispatcher
     主要是介紹當(dāng)有請(qǐng)求訪問SolrCore時(shí)SolrDispatchFilter如何處理。
    handleSelect是一個(gè)以前版本中遺留下來的屬性,會(huì)影響請(qǐng)求的對(duì)應(yīng)行為(比如/select?qt=XXX)。
    當(dāng)handleSelect="true"時(shí)導(dǎo)致SolrDispatchFilter將請(qǐng)求轉(zhuǎn)發(fā)給qt指定的處理器(前提是/select已經(jīng)注冊(cè))。
    當(dāng)handleSelect="false"時(shí)會(huì)直接訪問/select,若/select未注冊(cè)則為404。
    -->
   <requestDispatcher handleSelect="false" >

     <!-- Request Parsing:請(qǐng)求解析
        這些設(shè)置說明Solr Requests如何被解析,以及對(duì)ContentStreams有什么限制。

         enableRemoteStreaming - 是否允許使用stream.file和stream.url參數(shù)來指定遠(yuǎn)程streams。

         multipartUploadLimitInKB - 指定多文件上傳時(shí)Solr允許的最大的size。

         formdataUploadLimitInKB - 表單通過POST請(qǐng)求發(fā)送的最大size
       --> 
     <requestParsers enableRemoteStreaming="true"
                     multipartUploadLimitInKB="2048000"
                     formdataUploadLimitInKB="2048"/>

     <!-- HTTP Caching
         設(shè)置HTTP緩存的相關(guān)參數(shù)。
      -->
     <httpCaching never304="true" />

     <!--
       <httpCaching never304="true" >
          <cacheControl>max-age=30, public</cacheControl> 
        </httpCaching>
       -->

     <!--
       <httpCaching lastModifiedFrom="openTime"
                     etagSeed="Solr">
          <cacheControl>max-age=30, public</cacheControl> 
        </httpCaching>
       -->
   </requestDispatcher>


         10.requestHandler

                          請(qǐng)求處理器

<!-- Request Handlers 
     輸入的請(qǐng)求會(huì)通過請(qǐng)求中的路徑被轉(zhuǎn)發(fā)到特定的處理器。
    -->
   <!-- SearchHandler
     基本的請(qǐng)求處理器是SearchHandler,它提供一系列SearchComponents。
    通過multiple shards支持分布式。
    -->
   <requestHandler name="/select" class="solr.SearchHandler">
     <!-- 可以指定默認(rèn)值。-->
      <lst name="defaults">
        <str name="echoParams">explicit</str>
        <int name="rows">10</int>
        <str name="df">text</str>
      </lst>
     <!-- 添加屬性 -->
     <!--
       <lst name="appends">
          <str name="fq">inStock:true</str>
        </lst>
       -->

     <!-- 用法同上,盡量不要使用。-->
     <!--
       <lst name="invariants">
          <str name="facet.field">cat</str>
          <str name="facet.field">manu_exact</str>
          <str name="facet.query">price:[* TO 500]</str>
          <str name="facet.query">price:[500 TO *]</str>
        </lst>
       -->
     <!-- 下面的配置可以重置SearchComponents-->
     <!--
       <arr name="components">
          <str>nameOfCustomComponent1</str>
          <str>nameOfCustomComponent2</str>
        </arr>
       -->
     </requestHandler>

以上是“solrconfig.xml配置的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站欄目:solrconfig.xml配置的示例分析
網(wǎng)址分享:http://bm7419.com/article32/igecpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、網(wǎng)站排名、網(wǎng)站內(nèi)鏈、軟件開發(fā)、搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)