【solr专题之二】配置文件:solr.xml solrConfig.xml schema.xml
1、关于默认搜索域
<str name="qf">text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0</str>
由于content不占任何的权重,因此如果某个文档只在content中包含关键字的话,搜索结果并不会返回这个文档。因此,对于nutch提取的索引来说,要增加content的权重,以及url的权重(如果需要的话):
<str name="qf">content^1.0 text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0</str>
二、Search Handler
- <requestHandler name="/browse" class="solr.SearchHandler">
- <lst name="defaults">
- <str name="echoParams">explicit</str>
- <!-- VelocityResponseWriter settings -->
- <str name="wt">velocity</str>
- <str name="v.template">browse</str>
- <str name="v.layout">layout</str>
- <str name="title">Solritas_test</str>
- <!-- Query settings -->
- <str name="defType">edismax</str>
- <str name="qf">
- text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
- title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
- </str>
- <str name="df">content</str>
- <str name="mm">100%</str>
- <str name="q.alt">*:*</str>
- <str name="rows">10</str>
- <str name="fl">*,score</str>
- <!--more like this setting-->
- <str name="mlt.qf">
- text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
- title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
- </str>
- <str name="mlt.fl">text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename</str>
- <int name="mlt.count">3</int>
- <!-- Faceting defaults -->
- <str name="facet">on</str>
- <str name="facet.field">cat</str>
- <str name="facet.field">manu_exact</str>
- <str name="facet.field">content_type</str>
- <str name="facet.field">author_s</str>
- <str name="facet.query">ipod</str>
- <str name="facet.query">GB</str>
- <str name="facet.mincount">1</str>
- <str name="facet.pivot">cat,inStock</str>
- <str name="facet.range.other">after</str>
- <str name="facet.range">price</str>
- <int name="f.price.facet.range.start">0</int>
- <int name="f.price.facet.range.end">600</int>
- <int name="f.price.facet.range.gap">50</int>
- <str name="facet.range">popularity</str>
- <int name="f.popularity.facet.range.start">0</int>
- <int name="f.popularity.facet.range.end">10</int>
- <int name="f.popularity.facet.range.gap">3</int>
- <str name="facet.range">manufacturedate_dt</str>
- <str name="f.manufacturedate_dt.facet.range.start">NOW/YEAR-10YEARS</str>
- <str name="f.manufacturedate_dt.facet.range.end">NOW</str>
- <str name="f.manufacturedate_dt.facet.range.gap">+1YEAR</str>
- <str name="f.manufacturedate_dt.facet.range.other">before</str>
- <str name="f.manufacturedate_dt.facet.range.other">after</str>
- <!-- Highlighting defaults -->
- <str name="hl">on</str>
- <str name="hl.fl">content features title name</str>
- <str name="hl.encoder">html</str>
- <str name="hl.simple.pre"></str>
- <str name="hl.simple.post"></str>
- <str name="f.title.hl.fragsize">0</str>
- <str name="f.title.hl.alternateField">title</str>
- <str name="f.name.hl.fragsize">0</str>
- <str name="f.name.hl.alternateField">name</str>
- <str name="f.content.hl.snippets">3</str>
- <str name="f.content.hl.fragsize">200</str>
- <str name="f.content.hl.alternateField">content</str>
- <str name="f.content.hl.maxAlternateFieldLength">750</str>
- <!-- Spell checking defaults -->
- <str name="spellcheck">on</str>
- <str name="spellcheck.extendedResults">false</str>
- <str name="spellcheck.count">5</str>
- <str name="spellcheck.alternativeTermCount">2</str>
- <str name="spellcheck.maxResultsForSuggest">5</str>
- <str name="spellcheck.collate">true</str>
- <str name="spellcheck.collateExtendedResults">true</str>
- <str name="spellcheck.maxCollationTries">5</str>
- <str name="spellcheck.maxCollations">3</str>
- </lst>
- <!-- append spellchecking to our list of components -->
- <arr name="last-components">
- <str>spellcheck</str>
- </arr>
- </requestHandler>
1、SearchHandler是reqestHandler中的一种,它以requestHandler作为顶层元素。
2、二级元素包括first-components, last-components, defautls等。
3、Velocity的配置
- <!-- VelocityResponseWriter settings -->
- <str name="wt">velocity</str>
- <str name="v.template">browse</str>
- <str name="v.layout">layout</str>
- <str name="title">Solritas_test</str>
wt:指定返回搜索结果的格式
v.template: template name to use, without the .vm suffix. If not specified, "default"[.vm] will be used.
v.template.<name>: overrides a file system template
debugQuery: if true, default view displays explanations for each hit and additional debugging information in the footer.
v.json: Escapes and wraps Velocity generated response with v.json parameter as a JavaScript function.
v.layout: Template name that wraps main template (v.template). Main template renders to a $content that can be used in layout template.
v.base_dir: overwrites default template load path (conf/velocity/).
v.properties: specifies a Velocity properties file to be applied, found using the Solr resource loader mechanism. If not specified, no .properties file is loaded. Example: v.properties=velocity.properties where velocity.properties can be found using Solr's resource loader mechanism, for example in the conf/ directory (not conf/velocity which is for templates only). The .properties file could also be located inside a JAR in the lib/ directory, or other locations.
v.contentType: sets the value of the HTTP response's Content-Type header (in case (x)html pages should be UTF-8 (instead of ISO-8859-1) encoded, make sure you set this option to text/xml;charset=UTF-8 (for XHTML) and text/html;charset=UTF-8 (for HTML), respectively)
velocity的其余配置参考:http://blog.csdn.net/jediael_lu/article/details/38039267。
4、搜索域qf
- <str name="qf">
- text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
- title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
- </str>
定义了从哪些域进行搜索,以及各个域之间的权重。
5、QueryParser的选择 defType,常用efType=lucene, defType=edismax
- <str name="defType">edismax</str>
6、默认搜索域:df
若无指定搜索域,则此域作为默认的搜索域。
df/qf/defaultSearchField比较:
(1)使用solrConfig中的df属性代替schema中的defaultSearchField。
(2)df is the default field and will only take effect if the qf is not defined.
7、默认的query
- <str name="q.alt">*:*</str>
q.alt: 当q字段为空时,用于设置缺省的query,通常设置q.alt为*:*。
8、 mm:minimal should match。Solr支持三种查询clause,即“必须出现”, “不能出现”和“可以出现”,分别对应于AND, -, OR。
- <str name="mm">100%</str>
When dealing with queries there are 3 types of "clauses" that Lucene knows about: mandatory, prohibited, and 'optional' (aka: "SHOULD") By default all words or phrases specified in the "q" param are treated as "optional" clauses unless they are preceeded by a "+" or a "-". When dealing with these "optional" clauses, the "mm" option makes it possible to say that a certain minimum number of those clauses must match (mm). Specifying this minimum number can be done in complex ways, equating to ideas like...
At least 2 of the optional clauses must match, regardless of how many clauses there are: "2"
At least 75% of the optional clauses must match, rounded down: "75%"
If there are less than 3 optional clauses, they all must match; if there are 3 or more, then 75% must match, rounded up: "2<-25%"
If there are less than 3 optional clauses, they all must match; for 3 to 5 clauses, one less than the number of clauses must match, for 6 or more clauses, 80% must match, rounded down: "2<-1 5<80%"
Full details on the variety of complex expressions supported are explained in detail here.
In Solr 1.4 and prior, you should basically set mm=0 if you want the equivilent of q.op=OR, and mm=100% if you want the equivilent of q.op=AND. In 3.x and trunk the default value of mm is dictated by the q.op param (q.op=AND => mm=100%; q.op=OR => mm=0%). Keep in mind the default operator is effected by your schema.xml <solrQueryParser defaultOperator="xxx"/> entry. In older versions of Solr the default value is 100% (all clauses must match)
9、每页返回的行数
- <str name="rows">10</str>
10、返回Field的集合
- <str name="fl">*,score</str>
fl: 是逗号分隔的列表,用来指定文档结果中应返回的 Field 集。默认为 “*”,指所有的字段。以上即返回所有域,而加上score。
11、对返回结果排序
(1)排序的字段必须是index=true
(2)<str name="sort">tstamp asc</str>
若此元素放在<default>中,则指定默认元素,query时可以改变。
若放在<invariant>中,则在query中也不可以改变。
这应该对其它元素同样适用。
参考:http://stackoverflow.com/questions/24966924/how-to-change-the-default-rank-field-from-score-to-other-filed-in-solr/24971353#24971353
转载于:https://www.cnblogs.com/eaglegeek/p/4557878.html
【solr专题之二】配置文件:solr.xml solrConfig.xml schema.xml相关推荐
- Java Solr:(二)Solr 搜索原理
Solr 搜索原理 1.搜索原理 2.Solr 中数据存储说明 1.搜索原理 Solr 能够提升检索效率的主要原因就是分词和索引(反向索引). 分词:会对搜索条件/存储内容进行分词,分成日常所使用的词 ...
- 全文搜索技术 Lucene solr es (二)Solr(7.7.1)
学习视频地址:https://www.bilibili.com/video/av45567492?from=search&seid=14848044148453483902 本篇博客是基于此学 ...
- 二、Solr搜索原理
1.搜索原理 Solr能够提升检索效率的主要原因就是分词和索引(反向索引,通过). 分词:会对搜索条件/存储内容进行分词,分成日常所使用的词语. 索引:存储在Solr中内容会按照程序员的要求来是否建立 ...
- 初识SolrJ开发, schema.xml的配置与服务初始化.
schema.xml位于solr/collection1/conf/目录下,是Solr中用户定义字段类型及字段的配置文件. Solr版本: 4.6.0 第一步: Schema.xml说明 实例sche ...
- Apache Solr schema.xml及solrconfig.xml文件中文注解
一.字段配置(schema) schema.xml位于solr/conf/目录下,类似于数据表配置文件, 定义了加入索引的数据的数据类型,主要包括type.fields和其他的一些缺省设置. 1.先来 ...
- Solr 配置文件之schema.xml
schema.xml这个配置文件的根本目的是为了通过配置告诉Solr怎样建立索引. solr的数据结构例如以下: document:一个文档.一条记录 field:域.属性 solr通过搜索某个或某些 ...
- Solr基础教程之Schema.xml(二)
在 Solr 中,使用一个或多个 Document 来构建索引.Document 包括一个或多个 Field.Field 包括名称.内容以及告诉 Solr 如何处理内容的元数据. 例如,Field 可 ...
- 搜索引擎Solr系列(二): Solr6.2.1 从MySql中导入数据
一:建立MySql测试表,如下图: 二:solr导入配置: 1.新建demo core文件夹,并修改managed-schema里面的配置文件建立索引字段: 2.把mysql-connector-j ...
- 1、solr包结构介绍,solrCore的安装配置,solr部署到Tomcat,多solrCore配置,配置中文分词器,界面功能介绍,Schema.xml的基本使用,数据导入
一.下载solr,下载地址是:http://archive.apache.org/dist/lucene/solr/,选择自己想要的solr的版本,本项目使用的版本是4.10.3 二.如果想下载Luc ...
最新文章
- vue写一个通用的toast弹窗 toast 弹窗 提示
- linux 卸载 openssl,请教Linux下Openssl安装的问题。
- 新手python爬虫代码_新手小白必看 Python爬虫学习路线全面指导
- [转]如何将属性表嵌入对话框中显示
- LIS(基于贪心的O(NlogN)解法)
- CentOS7查看开放端口命令
- SQL Server-服务器迁移之后login登录问题
- C++ STL string的构造函数
- 线性代数基础(矩阵、范数、正交、特征值分解、奇异值分解、迹运算)
- 使用Java对sftp带有中文路径的文件夹进行下载,乱码打不开文件夹
- AI风向标:发改委重大工程项目公布,首个无人车路测试点落户亦庄
- JNI 概述 (翻译)
- E盾网络验证企业版离线版成品EXE DLL加密源码加密网络验证
- ug导出html,UG如何将工程图导出到CAD中?
- Trunk详解(笔记)
- 爬取煎蛋网图片(破解js)
- word-wrap长单词与URL地址自动换行
- 连接远程电脑的时候提示:此计算机无法连接到远程计算机
- 股票策略:A股三季度配置偏向成长股
- 计算机电池维修方案,解决方案:计算机主板电池已耗尽,如果不更换电池该怎么办?如何更换电池...