Solr IK 分词查不到结果问题

本文记录了在Solr4.6搭建过程中遇到的搜索功能限制问题及其解决过程。通过调整schema.xml的version属性从1.1到1.5,解决了只能全字匹配或单个字符匹配的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 前天在服务器上搭建一主一从的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

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

    翻译一下:

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

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

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

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

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

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值