`
ssxxjjii
  • 浏览: 931738 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

指尖上的电商---(6)solrconfig.xml配置详解

    博客分类:
  • solr
阅读更多

http://blog.csdn.net/zx13525079024/article/details/25310781

solrconfig.xml配置文件主要定义了SOLR的一些处理规则,包括索引数据的存放位置,更新,删除,查询的一些规则配置。

      可以在tomcat的安装路径下找到这个文件C:\Program Files\Apache Software Foundation\Tomcat 8.0\solr\collection1\conf

       1.datadir节点

         1.<dataDir>${solr.data.dir:d:/Server/Solr/data}</dataDir>定义了索引数据和日志文件的存放位置

       

     2.luceneMatchVersion

             <luceneMatchVersion>4.8</luceneMatchVersion>

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

      3. lib

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

         表示solr引用包的位置,当dir对应的目录不存在时候,会忽略此属性

 

      4.directoryFactory

          索引存储方案,共有以下存储方案

           1、solr.StandardDirectoryFactory,这是一个基于文件系统存储目录的工厂,它会试图选择最好的实现基于你当前的操作系统和Java虚拟机版本。
           2、solr.SimpleFSDirectoryFactory,适用于小型应用程序,不支持大数据和多线程。
           3、solr.NIOFSDirectoryFactory,适用于多线程环境,但是不适用在windows平台(很慢),是因为JVM还存在bug。
           4、solr.MMapDirectoryFactory,这个是solr3.1到4.0版本在linux64位系统下默认的实现。它是通过使用虚拟内存和内核特性调用

             mmap去访问存储在磁盘中的索引文件。它允许lucene或solr直接访问I/O缓存。如果不需要近实时搜索功能,使用此工厂是个不错的方案。
           5、solr.NRTCachingDirectoryFactory,此工厂设计目的是存储部分索引在内存中,从而加快了近实时搜索的速度。
           6、solr.RAMDirectoryFactory,这是一个内存存储方案,不能持久化存储,在系统重启或服务器crash时数据会丢失。且不支持索引复制

 

[html] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. <directoryFactory class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}" name="DirectoryFactory">  
  2.    <str name="solr.hdfs.home">${solr.hdfs.home:}</str>  
  3.    <str name="solr.hdfs.confdir">${solr.hdfs.confdir:}</str>  
  4.    <str name="solr.hdfs.blockcache.enabled">${solr.hdfs.blockcache.enabled:true}</str>  
  5.    <str name="solr.hdfs.blockcache.global">${solr.hdfs.blockcache.global:true}</str>  
  6. </directoryFactory>  

             5. codecFactory
                   编解码工厂允许使用自定义的编解码器。例如:如果想启动per-field DocValues格式, 可以在solrconfig.xml里面设置SchemaCodecFactory:
                    docValuesFormat="Lucene42": 这是默认设置,所有数据会被加载到堆内存中。
          docValuesFormat="Disk": 这是另外一个实现,将部分数据存储在磁盘上。
          docValuesFormat="SimpleText": 文本格式,非常慢,用于学习。

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

            6.indexconfig节点

                 用于设置索引的低级别的属性

      1、<filter class="solr.LimitTokenCountFilterFactory" maxTokenCount="10000"/>//限制token最大长度
      2、<writeLockTimeout>1000</writeLockTimeout>//IndexWriter等待解锁的最长时间(毫秒)。
      3、<maxIndexingThreads>8</maxIndexingThreads>//
      4、<useCompoundFile>false</useCompoundFile>//solr默认为false。如果为true,索引文件减少,检索性能降低,追求平衡。
      5、<ramBufferSizeMB>100</ramBufferSizeMB>//缓存
      6、<maxBufferedDocs>1000</maxBufferedDocs>//同上。两个同时定义时命中较低的那个。
      7、<mergePolicy class="org.apache.lucene.index.TieredMergePolicy">
         <int name="maxMergeAtOnce">10</int>
          <int name="segmentsPerTier">10</int>
         </mergePolicy>
          //合并策略。
      8、<mergeFactor>10</mergeFactor>//合并因子,每次合并多少个segments。
      9、<mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler"/>//合并调度器。
     10、<lockType>${solr.lock.type:native}</lockType>//锁工厂。
     11、<unlockOnStartup>false</unlockOnStartup>//是否启动时先解锁。
     12、<termIndexInterval>128</termIndexInterval>//Lucene loads terms into memory 间隔
     13、<reopenReaders>true</reopenReaders>//重新打开,替代先关闭-再打开。
     14、<deletionPolicy class="solr.SolrDeletionPolicy">//提交删除策略,必须实现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>//相当于把创建索引时的日志输出。

      <lockType>${solr.lock.type:native}</lockType>
       设置索引库的锁方式,主要有三种:
        1.single:适用于只读的索引库,即索引库是定死的,不会再更改
        2.native:使用本地操作系统的文件锁方式,不能用于多个solr服务共用同一个索引库。Solr3.6 及后期版本使用的默认锁机制。
        3.simple:使用简单的文件锁机制

    7. updateHandler节点

           定义更新处理器,

[html] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. <updateLog>  
  2.  <str name="dir">${solr.ulog.dir:}</str>  
  3.  </updateLog>  

                设置索引库更新日志,默认路径为solr home下面的data/tlog。随着索引库的频繁更新,tlog文件会越来越大,

        所以建议提交索引时采用硬提交方式<autoCommit>,即批量提交。       

[html] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. <autoCommit>  
  2.  <maxTime>15000</maxTime>  
  3.  <maxDocs>10000</maxDocs>  
  4.  <openSearcher>false</openSearcher>  
  5.  </autoCommit>  

          自动硬提交方式:maxTime:设置多长时间提交一次maxDocs:设置达到多少文档提交一次openSearcher:文档提交后是否开启新的searcher,

          如果false,文档只是提交到index索引库,搜索结果中搜不到此次提交的文档;如果true,既提交到index索引库,也能在搜索结果中搜到此次提交的内容。

                  

[html] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. <updateHandler class="solr.DirectUpdateHandler2">  
  2.     <!-- 允许事务日志  -->   
  3.     <updateLog>  
  4.       <str name="dir">${solr.ulog.dir:}</str>  
  5.     </updateLog>  
  6.   
  7.     <!--  
  8.    在满足一定条件时自动提交。maxDocs/maxTime/openSearcher 
  9.       -->  
  10.      <autoCommit>   
  11.        <maxTime>15000</maxTime>   
  12.        <openSearcher>false</openSearcher>   
  13.      </autoCommit>  
  14.   
  15.     <!-- 软提交VS硬提交 -->  
  16.      <!--  
  17.       <autoSoftCommit>   
  18.          <maxTime>1000</maxTime>   
  19.        </autoSoftCommit>  
  20.       -->  
  21.   
  22.     <!--   
  23.        更新相关事件监听器  
  24.         postCommit - fired after every commit or optimize command  
  25.          postOptimize - fired after every optimize command  
  26.       -->  
  27.     <!-- The RunExecutableListener executes an external command from a  
  28.          hook such as postCommit or postOptimize.  
  29.          exe - the name of the executable to run  
  30.          dir - dir to use as the current working directory. (default=".")  
  31.          wait - the calling thread waits until the executable returns.   
  32.                 (default="true")  
  33.          args - the arguments to pass to the program.  (default is none)  
  34.          env - environment variables to set.  (default is none)  
  35.       -->  
  36.     <!--  
  37.       <listener event="postCommit" class="solr.RunExecutableListener">  
  38.          <str name="exe">solr/bin/snapshooter</str>  
  39.          <str name="dir">.</str>  
  40.          <bool name="wait">true</bool>  
  41.          <arr name="args"> <str>arg1</str> <str>arg2</str> </arr>  
  42.          <arr name="env"> <str>MYVAR=val1</str> </arr>  
  43.        </listener>  
  44.       -->  
  45.   
  46.  </updateHandler>  


                 8.Query查询节点

             <maxBooleanClauses>1024</maxBooleanClauses>
             设置boolean 查询中,最大条件数。在范围搜索或者前缀搜索时,会产生大量的 boolean 条件,
             如果条件数达到这个数值时,将抛出异常,限制这个条件数,可以防止条件过多查询等待时间过长。

                             缓存方法http://www.cnblogs.com/phinecos/archive/2012/05/24/2517018.html

                         

[html] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. <filterCache class="solr.FastLRUCache" size="512" initialSize="512" autowarmCount="0"/>  
  2.   
  3. <queryResultCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0"/>  
  4.   
  5. <documentCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0"/>  
  6.   
  7. <queryResultMaxDocsCached>200</queryResultMaxDocsCached>  
  8.   
  9. <maxWarmingSearchers>2</maxWarmingSearchers>  


                9.Request Dispatcher

                        请求转发器

 

           

[html] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. <!-- Request Dispatcher  
  2.      主要是介绍当有请求访问SolrCore时SolrDispatchFilter如何处理。  
  3.     handleSelect是一个以前版本中遗留下来的属性,会影响请求的对应行为(比如/select?qt=XXX)。  
  4.     当handleSelect="true"时导致SolrDispatchFilter将请求转发给qt指定的处理器(前提是/select已经注册)。  
  5.     当handleSelect="false"时会直接访问/select,若/select未注册则为404。  
  6.     -->  
  7.    <requestDispatcher handleSelect="false" >  
  8.   
  9.      <!-- Request Parsing:请求解析  
  10.         这些设置说明Solr Requests如何被解析,以及对ContentStreams有什么限制。  
  11.   
  12.          enableRemoteStreaming - 是否允许使用stream.file和stream.url参数来指定远程streams。  
  13.   
  14.          multipartUploadLimitInKB - 指定多文件上传时Solr允许的最大的size。  
  15.   
  16.          formdataUploadLimitInKB - 表单通过POST请求发送的最大size  
  17.        -->   
  18.      <requestParsers enableRemoteStreaming="true"  
  19.                      multipartUploadLimitInKB="2048000"  
  20.                      formdataUploadLimitInKB="2048"/>  
  21.   
  22.      <!-- HTTP Caching  
  23.          设置HTTP缓存的相关参数。  
  24.       -->  
  25.      <httpCaching never304="true" />  
  26.   
  27.      <!--  
  28.        <httpCaching never304="true" >  
  29.           <cacheControl>max-age=30, public</cacheControl>   
  30.         </httpCaching>  
  31.        -->  
  32.   
  33.      <!--  
  34.        <httpCaching lastModifiedFrom="openTime"  
  35.                      etagSeed="Solr">  
  36.           <cacheControl>max-age=30, public</cacheControl>   
  37.         </httpCaching>  
  38.        -->  
  39.    </requestDispatcher>  


         10.requestHandler

                          请求处理器

 

           

[html] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. <!-- Request Handlers   
  2.      输入的请求会通过请求中的路径被转发到特定的处理器。  
  3.     -->  
  4.    <!-- SearchHandler  
  5.      基本的请求处理器是SearchHandler,它提供一系列SearchComponents。  
  6.     通过multiple shards支持分布式。  
  7.     -->  
  8.    <requestHandler name="/select" class="solr.SearchHandler">  
  9.      <!-- 可以指定默认值。-->  
  10.       <lst name="defaults">  
  11.         <str name="echoParams">explicit</str>  
  12.         <int name="rows">10</int>  
  13.         <str name="df">text</str>  
  14.       </lst>  
  15.      <!-- 添加属性 -->  
  16.      <!--  
  17.        <lst name="appends">  
  18.           <str name="fq">inStock:true</str>  
  19.         </lst>  
  20.        -->  
  21.   
  22.      <!-- 用法同上,尽量不要使用。-->  
  23.      <!--  
  24.        <lst name="invariants">  
  25.           <str name="facet.field">cat</str>  
  26.           <str name="facet.field">manu_exact</str>  
  27.           <str name="facet.query">price:[* TO 500]</str>  
  28.           <str name="facet.query">price:[500 TO *]</str>  
  29.         </lst>  
  30.        -->  
  31.      <!-- 下面的配置可以重置SearchComponents-->  
  32.      <!--  
  33.        <arr name="components">  
  34.           <str>nameOfCustomComponent1</str>  
  35.           <str>nameOfCustomComponent2</str>  
  36.         </arr>  
  37.        -->  
  38.      </requestHandler>  


 

 

      如果想更深入了解,可以参考下这几篇文章,

           http://wiki.apache.org/solr/SolrConfigXml/

          http://www.yunvn.com/thread-15932-1-1.html 

 

          http://www.luoshengsha.com/197.html    

分享到:
评论

相关推荐

    solrconfig.xml和schema.xml说明

    solrconfig.xml和schema.

    solr所需资源下载(数据导入、分词器、数据库连接jar、配置文件、managed-schema)

    包括solr的所有资源文件文件清单如下: IKAnalyzer.cfg.xml ik-analyzer-solr5-5.x.jar solr-analyzer-ik-5.1.0.jar managed-schema mysql-connector-java-5.1.7...solrconfig.xml data-config.xml ext.dic stopword.dic

    geonames-geocoder

    设置安装Solr 4.6.0,使用solrconfig.xml和schema.xml创建一个新集合。 从GeoNames( )下载美国数据并解压缩。 mvn包将target / geonames-geocoder-0.0.1-SNAPSHOT.jar复制到solr实例的WEB-INF / libs目录中。 运行...

    Eclipse开发分布式商城系统+完整视频代码及文档

    │ 12.nginx的配置文件-通过端口号区分虚拟机.avi │ 13.通过域名配置虚拟机.avi │ 淘淘商城第二天笔记.docx │ ├─03.第三天 │ 01.课程回顾.avi │ 02.课程计划.avi │ 03.什么是反向代理.avi │ 04.nginx的...

    wpsolr配置文件

    wpsolr配置文件,schema.xml、solrconfig.xml

    solr6对应的IKAnalyzer分词器

    2. 引入分词器的jar文件:在`server/solr/RD-Product/conf/solrconfig.xml`中配置如下信息,将`rd-lib`这个文件夹下的所有jar包引入到服务中。 &lt;!-- 引入"contrib/rd-lib/"下所有jar文件 --&gt; ${solr.install.dir:../...

    solr基础知识介绍

    5.2 solrconfig.xml 16 6.Solr缓存 18 6.1 filterCache 18 6.2 queryResultCache 18 6.3 documentCache 19 7.solrj wiki 19 7.1 SolrJ/Solr cross-version compatibility 19 7.2 Setting the classpath 20 7.2.1 ...

    solr-redis:Solr Redis扩展

    Solr Redis扩展该扩展是一个ParserPlugin,... 在solrconfig.xml配置查询解析器插件。 将以下内容添加到solrconfig.xml的“ config”部分: &lt; queryParser xss=removed xss=removed&gt; &lt; str xss=removed&gt;localhost&lt;/

    Solr 4.0 源代码实例

    附件包含100个以上示例,包括solr.xml、solrconfig.xml等在Jetty、Tomcat等应用服务器下的详细配置。

    Solr3.5开发应用指导

    基于Solr3.5的最新开发应用指导,文字加代码说明模式(Schedule.xml)、配置(solrconfig.xml)、索引,搜索等详细开发内容。

    solr全文检索

    里面有关于solr环境搭建的详细文档说明,还有schema.xml,solrconfig.xml这两个文件里的配置说明,还有创建索引,删除索引的代码。及性能的优化。

    Mining Solr In Action源代码

    针对Minging Solr in Action原版书的所有相关源代码示例及所有有关schema.xml, solrconfig.xml的详细配置示例,可以直接运行,配合教程再运行源代码更有助于深入理解、掌握solr全面知识点。

    Knowledge-Engine:专门用于搜索教师信息的基于知识的搜索引擎

    即,data-config.xml、schema.xml、solrconfig.xml 在mysql中创建一个名为knowledge_engine的数据库 更改 data-config.xml 中的数据库凭据 运行并索引 solr。 在访问知识引擎门户 ##提取单元 这是一个eclipse项目...

    Apache-Solr-Reference-Guide-v3.5

    begins with an overview of the file, then tells you how to configure cores solrconfig.xml with , how to configure the Lucene index writer, and more. solr.xml : This section discusses important topics ...

    solr schema solrconfig 配置文件解析

    solr schema solrconfig 配置文件解析 solr schema solrconfig 配置文件解析

    sunspot_solr_wildcard:基于sunspot_wildcard v2.2.0

    太阳黑子::: Sunspot :: Solr是Solr的... 如果指定solr home,则该目录必须包含conf目录,该目录至少应包含schema.xml和solrconfig.xml 。 确保将schema.xml复制到Sunspot gem的solr/solr/conf目录中。 Sunspot依赖

    SOLR的应用教程

    2.4.2 solrconfig.xml 25 3 Solr的应用 29 3.1 SOLR应用概述 29 3.1.1 Solr的应用模式 29 3.1.2 SOLR的使用过程说明 30 3.2 一个简单的例子 30 3.2.1 Solr Schema 设计 30 3.2.2 构建索引 30 3.2.3 搜索测试 31 3.3 ...

    ir-generalized-translation-models:Lucene&Solr中实现的概率相关性框架中的广义翻译模型

    有关相似性计算和可能的选项(可以在solrconfig.xml中定义)的信息,请参阅api存储库。结构扩展包含Lucene和Solr将要使用的扩展类+独立的单元和集成测试LuceneEvaluation包含将Lucene用于扩展的索引和评估代码(在

    apache solr Reference guide 4.5.pdf

    apache solr 官方文档(英文原版) 包含详细的安装、Schema配置、solrConfig配置、管理页面使用等.

    sails-solr:已弃用 - 用于 Sails.js 和 Waterline 的 Solr 适配器

    特征对接口支持自动完成作为模型方法和阴影路由操作的和拼写检查以分层导航(范围和面过滤器)作为模型方法和阴影路径操作的目录Solr Config API完整的 solrconfig 管理添加、更新 SearchComponents 添加、更新 ...

Global site tag (gtag.js) - Google Analytics