码迷,mamicode.com
首页 > 其他好文 > 详细

solr配置-Solrconfig.xml

时间:2014-11-07 23:15:30      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:des   Lucene   style   blog   http   io   color   ar   os   

可参考配置:http://wiki.apache.org/solr/SolrConfigXml

lib 

  <lib> 标签用于引入solr引用SolrPlugins的jar包,当dir对应的目录不存在时,solr会忽略此,

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

dataDir parameter

  配置data目录的存放位置,data目录中存放了index和log文件。默认为solr home下面的data文件夹

<dataDir>${solr.data.dir:E:/solr/example/solr/collection1/data}</dataDir>

codecFactory

  允许使用用户自定义的解码器,默认是SchemaCodecFactory

 <codecFactory class="solr.SchemaCodecFactory"/>

以下配置由于内容比较多,直接采用配置文件夹注解的形式

indexConfig

  

 <indexConfig>
    <!-- Maximum time to wait for a write lock (ms) for an IndexWriter. Default: 1000 -->
    <!-- <writeLockTimeout>1000</writeLockTimeout>  -->

    <!-- indexWriter生成索引时使用的最大线程数 Default in Solr/Lucene is 8. -->
    <maxIndexingThreads>8</maxIndexingThreads>

    <!-- 通过将很多 Lucene 内部文件整合到一个文件来减少使用中的文件的数量。
    这可有助于减少 Solr 使用的文件句柄数目,代价是降低了性能。
    除非是应用程序用完了文件句柄,否则 false 的默认值应该就已经足够
     Default in Lucene is "true". Default in Solr is "false" (since 3.6) -->
   <useCompoundFile>false</useCompoundFile>

    <!-- ramBufferSizeMB maxBufferedDocs 在添加或删除文档时,为了减少频繁的更些索引,
    Solr会选缓存在内存中,当内存中的文件大于设置的值,才会更新到索引库。
    较大的值可使索引时间变快但会牺牲较多的内存。
    如两个值同时设置,满足一个就会进行刷新索引.  -->
    <ramBufferSizeMB>100</ramBufferSizeMB>
    <maxBufferedDocs>1000</maxBufferedDocs>

    <!-- Expert: Merge Policy 
         The Merge Policy in Lucene controls how merging of segments is done.
         The default since Solr/Lucene 3.3 is TieredMergePolicy.
         The default since Lucene 2.3 was the LogByteSizeMergePolicy,
         Even older versions of Lucene used LogDocMergePolicy.
      -->
    <!--
        <mergePolicy class="org.apache.lucene.index.TieredMergePolicy">
          <int name="maxMergeAtOnce">10</int>
          <int name="segmentsPerTier">10</int>
        </mergePolicy>
      -->
       
    <!-- Merge Factor决定低水平的 Lucene 段被合并的频率。
    较小的值(最小为 2)使用的内存较少但导致的索引时间也更慢。
    较大的值可使索引时间变快但会牺牲较多的内存。-->

    <mergeFactor>10</mergeFactor>

    <!-- Expert: Merge Scheduler
         The Merge Scheduler in Lucene controls how merges are
         performed.  The ConcurrentMergeScheduler (Lucene 2.3 default)
         can perform merges in the background using separate threads.
         The SerialMergeScheduler (Lucene 2.2 default) does not.
     -->
    <!-- 
       <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler"/>
       -->

    <!-- LockFactory 配置锁
         single = SingleInstanceLockFactory - 在只读索引或是没有其它进程修改索引时使用.
         native = NativeFSLockFactory - 在只读索引或是没有其它进程修改索引时使用.
         simple = SimpleFSLockFactory  - 使用一个文本文件锁定索引.

         Defaults: ‘native‘ is default for Solr3.6 and later, otherwise
                   ‘simple‘ is the default -->
    <lockType>${solr.lock.type:native}</lockType>

    <!-- unlockOnStartup 告知 Solr 忽略在多线程环境中用来保护索引的锁定机制。
        在某些情况下,索引可能会由于不正确的关机或其他错误而一直处于锁定,
        这就妨碍了添加和更新。将其设置为 true 可以禁用启动锁定,进而允许进行添加和更新。
        Default is "false". This is not needed if lock type is ‘single‘ -->
    
    <unlockOnStartup>false</unlockOnStartup>
      
    
    <!-- Expert: Controls how often Lucene loads terms into memory
         Default is 128 and is likely good for most everyone.
      -->
    <!-- <termIndexInterval>128</termIndexInterval> -->

    <!-- If true, IndexReaders will be opened/reopened from the IndexWriter
         instead of from the Directory. Hosts in a master/slave setup
         should have this set to false while those in a SolrCloud
         cluster need to be set to true. Default: true
      -->
    <!-- 
    <nrtMode>true</nrtMode>
      -->

    <!-- Commit Deletion Policy
         Custom deletion policies can be specified here. The class must
         implement org.apache.lucene.index.IndexDeletionPolicy.

         The default Solr IndexDeletionPolicy implementation supports
         deleting index commit points on number of commits, age of
         commit point and optimized status.
         
         The latest commit point should always be preserved regardless
         of the criteria.
    -->
    <!-- 
    <deletionPolicy class="solr.SolrDeletionPolicy">
    -->
      <!-- The number of commit points to be kept -->
      <!-- <str name="maxCommitsToKeep">1</str> -->
      <!-- The number of optimized commit points to be kept -->
      <!-- <str name="maxOptimizedCommitsToKeep">0</str> -->
      <!--
          Delete all commit points once they have reached the given age.
          Supports DateMathParser syntax e.g.
        -->
      <!--
         <str name="maxCommitAge">30MINUTES</str>
         <str name="maxCommitAge">1DAY</str>
      -->
    <!-- 
    </deletionPolicy>
    -->

    <!-- Lucene Infostream
       
         To aid in advanced debugging, Lucene provides an "InfoStream"
         of detailed information when indexing.

         Setting the value to true will instruct the underlying Lucene
         IndexWriter to write its info stream to solr‘s log. By default,
         this is enabled here, and controlled through log4j.properties.
      -->
     <infoStream>true</infoStream>
    
    <!--
        Use true to enable this safety check, which can help
        reduce the risk of propagating index corruption from older segments 
        into new ones, at the expense of slower merging.
    -->
     <checkIntegrityAtMerge>false</checkIntegrityAtMerge>
  </indexConfig>

Update Handler

<!--updateHandler: 这个更新处理器主要涉及底层的关于如何更新处理内部的信息。 -->
 <updateHandler class="solr.DirectUpdateHandler2">

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

    <autoCommit>    
      <maxDocs>10000</maxDocs> <!-- 触发自动提交前最多可以等待提交的文档数量  -->   
      <maxTime>86000</maxTime> <!-- 在添加了一个文档之后,触发自动提交之前所最大的等待时间--> 
    </autoCommit>   
  
    <!--一个postCommit的事件被触发当每一个提交之后  -->
    <listener event="postCommit" class="solr.RunExecutableListener">   
      <str name="exe">snapshooter</str>   <!-- exe--可执行的文件类型   -->
      <str name="dir">solr/bin</str>   <!--dir--可以用该目录做为当前的工作目录。默认为"."    -->
      <bool name="wait">true</bool>   <!-- wait--调用线程要等到可执行的返回值   --> 
      <arr name="args"> <str>arg1</str> <str>arg2</str> </arr>  <!--args--传递给程序的参数 默认nothing-->
      <arr name="env"> <str>MYVAR=val1</str> </arr>  <!-- env 环境变量的设置 默认nothing    --> 
       
    </listener>   

     <autoSoftCommit> 
       <maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime> 
     </autoSoftCommit>

 </updateHandler>

query

maxBooleanClauses

最大的BooleanQuery数量. 当值超出时,抛出 TooManyClausesException.注意这个是全局的,如果是多个SolrCore都会使用一个值,每个Core里设置不一样的化,会使用最后一个的.

filterCache

filterCache存储了无序的lucene document id集合,1.存储了filter queries(“fq”参数)得到的document id集合结果。2还可用于facet查询3. 3)如果配置了useFilterForSortedQuery,那么如果查询有filter,则使用filterCache。

queryResultCache

缓存搜索结果,一个文档ID列表

documentCache

缓存Lucene的Document对象,不会自热

fieldValueCache

字段缓存使用文档ID进行快速访问。默认情况下创建fieldValueCache即使这里没有配置。

enableLazyFieldLoading

若应用程序预期只会检索 Document 上少数几个 Field,那么可以将属性设置为 true。延迟加载的一个常见场景大都发生在应用程序返回和显示一系列搜索结果的时候,用户常常会单击其中的一个来查看存储在此索引中的原始文档。初始的 显示常常只需要显示很短的一段信息。若考虑到检索大型 Document 的代价,除非必需,否则就应该避免加载整个文档。

queryResultWindowSize

一次查询中存储最多的doc的id数目.

queryResultMaxDocsCached

查询结果doc的最大缓存数量, 例如要求每页显示10条,这里设置是20条,也就是说缓存里总会给你多出10条的数据.让你点示下一页时很快拿到数据.

listener

选项定义 newSearcher 和 firstSearcher 事件,您可以使用这些事件来指定实例化新搜索程序或第一个搜索程序时应该执行哪些查询。如果应用程序期望请求某些特定的查询,那么在创建新搜索程序或第一 个搜索程序时就应该反注释这些部分并执行适当的查询。

useColdSearcher

是否使用冷搜索,为false时使用自热后的searcher

maxWarmingSearchers

最大自热searcher数量

requestDispatcher

Solr‘s HTTP RequestDispatcher 配置如何处理各种HTTP请求解析;远程媒体流的支持;multipart 文件上传大小,等

<!--
    Let the dispatch filter handler /select?qt=XXX
    handleSelect=true will use consistent error handling for /select and /update
    handleSelect=false will use solr1.1 style error formatting
    -->
  <requestDispatcher handleSelect="true" >
    <!--Make sure your system has some authentication before enabling remote streaming!  -->
    <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" formdataUploadLimitInKB="2048" />

  ...

未完。。。

 

solr配置-Solrconfig.xml

标签:des   Lucene   style   blog   http   io   color   ar   os   

原文地址:http://www.cnblogs.com/whatadiors/p/4082414.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!