【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 the defaultSearchField. The DisMax and Extended DisMax query parsers do not use this value.?Use of the defaultSearchField element is deprecated in Solr versions 3.6 and higher. Instead, you should use the df request parameter. At some point, the defaultSearchField element may be removed。 即使用solrConfig中的df屬性代替schema中的defaultSearchField。
2、關于qf
從solr的example中得到的solrConfig.xml中,qf的定義如下: <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
[html]?view plaincopy
2、二級元素包括first-components, ?last-components, defautls等。
3、Velocity的配置
[html]?view plaincopy
-
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
[html]?view plaincopy
5、QueryParser的選擇 defType,常用efType=lucene, defType=edismax
[html]?view plaincopy
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
[html]?view plaincopy
q.alt: 當q字段為空時,用于設置缺省的query,通常設置q.alt為*:*。
8、?mm:minimal should match。Solr支持三種查詢clause,即“必須出現”, “不能出現”和“可以出現”,分別對應于AND, -, OR。
[html]?view plaincopy
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、每頁返回的行數[html]?view plaincopy
10、返回Field的集合
[html]?view plaincopy
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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hadoop集群三种作业调度算法介绍
- 下一篇: C语言的本质(35)——共享库