现在的位置: 首页 > 综合 > 正文

solr4.6关于schema.xml版本号的问题

2018年05月24日 ⁄ 综合 ⁄ 共 1543字 ⁄ 字号 评论关闭

    前天在服务器上搭建一主一从的solr4.6的服务器,建core的时候,抛弃了以前从solr4.6下载包里面的配置文件。而是上这个文件夹拿配置文件:F:\solr\solr-4.6.0\example\multicore\core0\conf。这个文件夹给的配置文件是最简单的!只需一个schema.xml和solrconfig.xml就可以迅速搭建一个core出来。

    搭建好之后,基本的CRUD操作都可以。但是搜索却只能全字匹配或者只能单个字符匹配出结果。这是绝对不能容忍的。定位问题接近了一天,找有经验的同事给排查也没排查出来问题。最后我自己一点一点比对multicore文件夹下的配置文件跟F:\solr\solr-4.6.0\example\solr\collection1这个文件夹下的配置文件的配置区别。

    当我把schema.xml的version属性从1.1升到跟collection1下的相同文件的1.5一致之后。重启服务器,问题解决了!

    我只想想说,提供solr4.6包的工程师坑爹。schema.xml的version属性对搜索的效果影响重大,4.6下的multicore提供的版本号却是古老的1.1.

    查了下schema.xml的官方文档:http://wiki.apache.org/solr/SchemaXml

<schema name="example" version="1.5">
49	  <!-- attribute "name" is the name of this schema and is only used for display purposes.
50	       version="x.y" is Solr's version number for the schema syntax and 
51	       semantics.  It should not normally be changed by applications.
52	
53	       1.0: multiValued attribute did not exist, all fields are multiValued 
54	            by nature
55	       1.1: multiValued attribute introduced, false by default 
56	       1.2: omitTermFreqAndPositions attribute introduced, true by default 
57	            except for text fields.
58	       1.3: removed optional field compress feature
59	       1.4: autoGeneratePhraseQueries attribute introduced to drive QueryParser
60	            behavior when a single string produces multiple tokens.  Defaults 
61	            to off for version >= 1.4
62	       1.5: omitNorms defaults to true for primitive field types 
63	            (int, float, boolean, string...)
64	     -->

    翻译一下:

    1.0:多值属性不存在,所有的域本质上是多值属性

    1.1:多值属性被引进,默认为false

1.2:omitTermFreqAndPositions属性被引进,默认为true,文本域除外

1.3:删除可选的域压缩特性

1.4:当单个字符串产生多个词的时候,autoGeneratePhraseQueries 属性被引进以驱动查询分析器行为。版本大于等于1.4默认被关闭

1.5:对于原子类型,omitNorms属性默认为true

    从官方文档上可以看出,版本号不一样,shema.xml被解析出来的效果也是不一样的。

抱歉!评论已关闭.