solr4.7.2使用IK分词后部分词查不到数据

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-28 12:08   38   0

配置IK分词器

schema.xml

<!-- 原始 ik分词器 -->    
    <fieldType name="text_ik" class="solr.TextField">         
         <analyzer type="index" useSmart="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
        
         <analyzer type="query" useSmart="true" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
    </fieldType>   

分词效果

但是分词后使用 "中华人民",“人民共和国”,“共和国” 都查不到数据,使用 “人民” ,“美丽” 能查到数据,很奇怪

schema.xml

apache官网介绍:https://cwiki.apache.org/confluence/display/solr/SchemaXml

<schema name="example" version="1.5">
  <!-- attribute "name" is the name of this schema and is only used for display purposes.
       version="x.y" is Solr's version number for the schema syntax and
       semantics.  It should not normally be changed by applications.

       1.0: multiValued attribute did not exist, all fields are multiValued
            by nature
       1.1: multiValued attribute introduced, false by default
       1.2: omitTermFreqAndPositions attribute introduced, true by default
            except for text fields.
       1.3: removed optional field compress feature
       1.4: autoGeneratePhraseQueries attribute introduced to drive QueryParser
            behavior when a single string produces multiple tokens.  Defaults
            to off for version >= 1.4
       1.5: omitNorms defaults to true for primitive field types
            (int, float, boolean, string...)
     -->

发现version版本不同,schema.xml被解析的效果也不一样,发现solr4.7.2自带的例子中

collecton1

<schema name="example" version="1.5">

core0

<schema name="example core zero" version="1.1">

core1

<schema name="example core one" version="1.1">

我刚好测试时拷贝的是core0的,导致version=1.1,分词后查询不到数据,改成1.5就可以了

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP