美文网首页
Solr中文分词

Solr中文分词

作者: __youzhiyong | 来源:发表于2017-12-21 17:28 被阅读0次
  1. 导入相应的jar包。添加到WEB-INF/lib下
  2. 在需要使用中文分词的core下的managed-schema文件定义一个关于分词的字段类型<fieldType>
  3. 把需要使用的字段的type属性替换成自定义的字段类型的name

例如:使用solr自带的中文分词

  1. 导入jar包
    将D:\solr-6.6.1\contrib\analysis-extras\lucene-libs\lucene-analyzers-smartcn-6.6.1.jar添加到WEB-INF/lib下
  2. 在managed-schema文件中定义
<fieldType>
    <fieldType name="text_smartcn" class="solr.TextField" positionIncrementGap="0">
      <analyzer type="index">
        <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>
      </analyzer>
    </fieldType>
  1. 在需要的字段中使用
    <field name="content" type="text_smartcn" indexed="true" stored="true"/>

相关文章

网友评论

      本文标题:Solr中文分词

      本文链接:https://www.haomeiwen.com/subject/bfgawxtx.html