Solr入门之(6)配置文件solrconfig.xml
solrconfig.xml包含了用于配置自身行为的绝大部分参数,其作用范围是当前core。该文件位于${solr_home}/solr/core1/conf/下。
参数列表概览:
A、lib
B、dataDir parameter
C、directoryFactory
D、codecFactory
E、indexConfig Section
F、Update Handler Section
G、The Query Section
H、Request Dispatcher
I、Request Handler Plug-in Section
J、UpdateRequestProcessorChain section
K、The Highlighter plugin configuration section
L、The Admin/GUI Section
M、System property substitution
N、Enable/disable components
O、XInclude
P、Includes via Document Entities
一、lib:
1、<lib/>标签用于加载solr所需要的jar包,从而支持solrconfig.xml 或者 schema.xml中定义的插件(例如:Analyzers,Request Handlers...)
2、所有的路径都是相对路径,相对于当前实例文件夹${solr_home}/solr/core1
3、在定义<lib/>时需要注意各个jar包之间的依赖,从而按照正确的顺序引入。例如:jar1依赖jar2,那么必须把jar2定义在jar1之前。
4、如果存在"./lib"文件夹,将会默认将其中所有的jar包引入。类似于语法:<lib dir="./lib" />
5、相当于把<lib/>中引用的所有jar包加入到了classpath中。
6、当存在regex属性时,进行过滤。
实例代码:
<lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />
<lib dir="/non/existent/dir/yields/warning" />
二、dataDir parameter:
solr默认将索引文件存放在${solr_home}/data目录下。而<dataDir>可以设置索引文件存放在任意指定的目录下。
如果配置了replication,那么这里的定义需要与其匹配。
<dataDir>${solr.data.dir:}</dataDir>
三、directoryFactory:
用于定义选择索引存储方案,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时数据会丢失。且不支持索引复制。
四、codecFactory:
编解码工厂允许使用自定义的编解码器。例如:如果想启动per-field DocValues格式, 可以在solrconfig.xml里面设置SchemaCodecFactory:
<codecFactory class="solr.SchemaCodecFactory"/>
五、indexConfig Section:
该模块用于设置索引的低级别的属性。
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>
18、<infoStream file="INFOSTREAM.txt">false</infoStream>//相当于把创建索引时的日志输出。
六、Update Handler Section:
该模块用于定义更新处理器。
<updateHandler class="solr.DirectUpdateHandler2">
<!-- 允许事务日志 -->
<updateLog>
<str name="dir">${solr.ulog.dir:}</str>
</updateLog> <!--
在满足一定条件时自动提交。maxDocs/maxTime/openSearcher
-->
<autoCommit>
<maxTime>15000</maxTime>
<openSearcher>false</openSearcher>
</autoCommit> <!-- 软提交VS硬提交 -->
<!--
<autoSoftCommit>
<maxTime>1000</maxTime>
</autoSoftCommit>
--> <!--
更新相关事件监听器
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>
--> </updateHandler>
七、The Query Section:
该模块用于设置查询时的一些处理,涉及到solr的调优,后续分析。
1、<maxBooleanClauses>1024</maxBooleanClauses>
2、各种Cache的使用,详情参考博文http://www.cnblogs.com/phinecos/archive/2012/05/24/2517018.html
3、<enableLazyFieldLoading>true</enableLazyFieldLoading>
4、<useFilterForSortedQuery>true</useFilterForSortedQuery>
5、<queryResultWindowSize>20</queryResultWindowSize>
6、<queryResultMaxDocsCached>200</queryResultMaxDocsCached>
7、<listener>
8、<useColdSearcher>false</useColdSearcher>
9、<maxWarmingSearchers>2</maxWarmingSearchers>
示例代码:
<query> <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"/> <!--
<fieldValueCache class="solr.FastLRUCache"
size="512"
autowarmCount="128"
showItems="32" />
--> <!--
<cache name="myUserCache"
class="solr.LRUCache"
size="4096"
initialSize="1024"
autowarmCount="1024"
regenerator="com.mycompany.MyRegenerator"
/>
--> <enableLazyFieldLoading>true</enableLazyFieldLoading> <!--
<useFilterForSortedQuery>true</useFilterForSortedQuery>
--> <queryResultWindowSize>20</queryResultWindowSize> <queryResultMaxDocsCached>200</queryResultMaxDocsCached> <listener event="newSearcher" class="solr.QuerySenderListener">
<arr name="queries">
<!--
<lst><str name="q">solr</str><str name="sort">price asc</str></lst>
<lst><str name="q">rocks</str><str name="sort">weight asc</str></lst>
-->
</arr>
</listener>
<listener event="firstSearcher" class="solr.QuerySenderListener">
<arr name="queries">
<lst>
<str name="q">static firstSearcher warming in solrconfig.xml</str>
</lst>
</arr>
</listener> <useColdSearcher>false</useColdSearcher> <maxWarmingSearchers>2</maxWarmingSearchers> </query>
8、Request Dispatcher:
请求转发器。
<!-- Request Dispatcher
主要是介绍当有请求访问SolrCore时SolrDispatchFilter如何处理。
handleSelect是一个以前版本中遗留下来的属性,会影响请求的对应行为(比如/select?qt=XXX)。
当handleSelect="true"时导致SolrDispatchFilter将请求转发给qt指定的处理器(前提是/select已经注册)。
当handleSelect="false"时会直接访问/select,若/select未注册则为404。
-->
<requestDispatcher handleSelect="false" > <!-- Request Parsing:请求解析
这些设置说明Solr Requests如何被解析,以及对ContentStreams有什么限制。 enableRemoteStreaming - 是否允许使用stream.file和stream.url参数来指定远程streams。 multipartUploadLimitInKB - 指定多文件上传时Solr允许的最大的size。 formdataUploadLimitInKB - 表单通过POST请求发送的最大size
-->
<requestParsers enableRemoteStreaming="true"
multipartUploadLimitInKB="2048000"
formdataUploadLimitInKB="2048"/> <!-- HTTP Caching
设置HTTP缓存的相关参数。
-->
<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>
9、Request Handler Plug-in Section:
请求处理器插件模块,可以在这里定义各种请求处理器。
A、第一个示例代码,后续中的参数设置与此相同:
<!-- Request Handlers
输入的请求会通过请求中的路径被转发到特定的处理器。
-->
<!-- SearchHandler
基本的请求处理器是SearchHandler,它提供一系列SearchComponents。
通过multiple shards支持分布式。
-->
<requestHandler name="/select" class="solr.SearchHandler">
<!-- 可以指定默认值。-->
<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>
10、UpdateRequestProcessorChain section:
此处暂时不做说明,后续补充。
示例代码:
<!-- Update Processors -->
<!-- Deduplication -->
<!---->
<updateRequestProcessorChain name="dedupe">
<processor class="solr.processor.SignatureUpdateProcessorFactory">
<bool name="enabled">true</bool>
<str name="signatureField">id</str>
<bool name="overwriteDupes">false</bool>
<str name="fields">name,features,cat</str>
<str name="signatureClass">solr.processor.Lookup3Signature</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain> <!-- Language identification -->
<!---->
<updateRequestProcessorChain name="langid">
<processor class="org.apache.solr.update.processor.TikaLanguageIdentifierUpdateProcessorFactory">
<str name="langid.fl">text,title,subject,description</str>
<str name="langid.langField">language_s</str>
<str name="langid.fallback">en</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain> <!-- Script update processor -->
<!-- -->
<updateRequestProcessorChain name="script">
<processor class="solr.StatelessScriptUpdateProcessorFactory">
<str name="script">update-script.js</str>
<lst name="params">
<str name="config_param">example config parameter</str>
</lst>
</processor>
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
11、Response Writers:
后续讨论,见名知意。
实例代码:
<!-- Response Writers 响应对象通过wt参数中指定的writer写回数据。-->
<!--
<queryResponseWriter name="xml"
default="true"
class="solr.XMLResponseWriter" />
<queryResponseWriter name="json" class="solr.JSONResponseWriter"/>
<queryResponseWriter name="python" class="solr.PythonResponseWriter"/>
<queryResponseWriter name="ruby" class="solr.RubyResponseWriter"/>
<queryResponseWriter name="php" class="solr.PHPResponseWriter"/>
<queryResponseWriter name="phps" class="solr.PHPSerializedResponseWriter"/>
<queryResponseWriter name="csv" class="solr.CSVResponseWriter"/>
<queryResponseWriter name="schema.xml" class="solr.SchemaXmlResponseWriter"/>
--> <queryResponseWriter name="json" class="solr.JSONResponseWriter">
<str name="content-type">text/plain; charset=UTF-8</str>
</queryResponseWriter> <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" startup="lazy"/> <queryResponseWriter name="xslt" class="solr.XSLTResponseWriter">
<int name="xsltCacheLifetimeSeconds">5</int>
</queryResponseWriter>
12、Query Parsers:
<!-- Query Parsers -->
<queryParser name="myparser" class="com.mycompany.MyQParserPlugin"/> <!-- Function Parsers
Multiple ValueSourceParsers can be registered by name, and then
used as function names when using the "func" QParser.
-->
<!-- example of registering a custom function parser -->
<valueSourceParser name="myfunc"
class="com.mycompany.MyValueSourceParser" />
Solr入门之(6)配置文件solrconfig.xml的更多相关文章
- Solr 02 - 最详细的solrconfig.xml配置文件解读
目录 1 luceneMatchVersion - 指定Lucene版本 2 lib - 配置扩展jar包 3 dataDir - 索引数据路径 4 directoryFactory - 索引存储工厂 ...
- Solr 6.7学习笔记(03)-- 样例配置文件 solrconfig.xml
位于:${solr.home}\example\techproducts\solr\techproducts\conf\solrconfig.xml <?xml version="1. ...
- solrconfig.xml解析
solrconfig.xml配置文件主要定义了SOLR的一些处理规则,包括索引数据的存放位置,更新,删除,查询的一些规则配置.下面将对solrconfig进行详细描述:1 <luceneMatc ...
- solr入门之solr的拼写检查功能的应用级别尝试
今天主要是收集了些拼写检查方面的资料和 尝试使用一下拼写检查的功能--=遇到了不少问题 拼写检查的四种配置眼下我仅仅算是成功了半个吧 --------------------------------- ...
- Solr入门-Solr服务安装(windows系统)
安装Solr 首先保证已经正确安装了Java 下载Solr,当前最新版6.1.0 Solr各个版本下载地址 Solr从6.0之后需要Java1.8所以如果使用Solr6.0及其以上版本,请确保Java ...
- 【solr专题之二】配置文件:solr.xml solrConfig.xml schema.xml
1.关于默认搜索域 If you are using the Lucene query parser, queries that don't specify a field name will use ...
- 【solr专题之二】配置文件:solr.xml solrConfig.xml schema.xml 分类: H4_SOLR/LUCENCE 2014-07-23 21:30 1959人阅读 评论(0) 收藏
1.关于默认搜索域 If you are using the Lucene query parser, queries that don't specify a field name will use ...
- Solr Schema.xml和solrconfig.xml分析(转)
Solr Schema.xml和solrconfig.xml分析 (http://yinwufeng.iteye.com/blog/964040) 一.字段配置(schema) schema.xml位 ...
- 利用SOLR搭建企业搜索平台 之——solr配置solrconfig.xml
来源:http://blog.csdn.net/zx13525079024/article/details/25310781 solrconfig.xml配置文件主要定义了SOLR的一些处理规则,包括 ...
随机推荐
- 有关在线OJ网络AC爬虫
搜索源码 爬取代码 自动登录 在线提交 判断AC
- oracle数据库常用plsql语句
(一)oracle中常用的数据类型 (二)PL-sql基本语法 1.创建数据库表.删除数据库表 create table table1--创建表 ( field1 number(8), field2 ...
- 【leetcode】Insert Interval
Insert Interval Given a set of non-overlapping intervals, insert a new interval into the intervals ( ...
- C#跨线程操作控件
1.首先通过按键创建子线程: 创建子线程,子线程调用changeText方法. private void btnOK_Click(object sender, EventArgs e) { Threa ...
- java切换VPN让你像幽灵一样出现在全国各地
在很多情况下,有些网络应用的需求会要求模拟人在不同地区访问网站和应用.因而切换IP也就应运而生了,然而IP作为一种稀缺资源不是随便可以获得的.因而会想到应用程序切换VPN来达到全国不同地区访问网络.因 ...
- Google Code Jam 2015 R1C B
题意:给出一个键盘,按键都是大写字母.给出一个目标单词和一个长度L.最大值或者最大长度都是100.现在随机按键盘,每个按键的概率相同. 敲击出一个长度为L的序列.求该序列中目标单词最多可能出现几次,期 ...
- DELPHI XE5开发WEB服务器及安卓手机客户端
Xe5开发web服务端和手机客户端 ------------------------------------- Delphi xe5作为最新开发利器,就类似如当年的DELPHI,功能强大,快发速度快, ...
- linux expect
1.首先确定是否安装expect /home/root> which expect /usr/bin/expect 如果没有安装,先安装一下 安装方法: 请参考 http://www.cnblo ...
- Ditto - Windows剪贴板增强小工具,方便复制粘贴多条记录
在平时的工作中,好多地方需要重复的复制粘帖一些重复性的代码,频繁的Ctrl+C.Ctrl+V导致效率很低,而且时间长了会很烦,Windows自带的剪切板功能一次只能进行一条记录操作,单一的不行,与提高 ...
- codeforces 577B. Modulo Sum 解题报告
题目链接:http://codeforces.com/problemset/problem/577/B 题目意思:就是给出 n 个数(a1, a2, ..., an) 和 m,问能不能从这 n 个数中 ...