Solr6.5环境配置和中文分词配置

1 篇文章 0 订阅
1 篇文章 0 订阅

Solr6.5

Solr6.5下载下来之后,因为其本身包含jetty服务,不需要部署到tomcat中即可直接运行

1:进入目录D:\dev\solr-6.5.1\solr-6.5.1\bin,
新建两个bat文件:solr start -p 8984 / solr stop -p 8984
用于快捷开启关闭solr服务。

2:开启服务后,进入127.0.0.1:8984/solr/

3:这是是没有对应的core,需要我们手动新建,这里要注意几点,
D:\dev\solr-6.5.1\solr-6.5.1\server\solr 到这个目录下,手动创建你要新建的core,名称一致,这里用collection,
collection下新建data文件夹,同时将D:\dev\solr-6.5.1\solr-6.5.1\server\solr\configsets\basic_configs 下的config文件夹复制到collection。这时候在管理界面新建collection 即可顺利创建。

4:配置schema:这里配置需要注意的是
普通要增加的检索直接用:

<!-- 用到的field -->
   <field name="columnId" type="long" indexed="true" stored="true" multiValued="false"/>
   <field name="title" type="text_general" indexed="true" stored="true" multiValued="false"/>
    <field name="titlePinyin" type="text_pinyin" indexed="true" stored="true" multiValued="false"/>
   <field name="remark" type="text_general" indexed="true" stored="true" multiValued="false"/>
   <field name="content" type="text_general" indexed="true" stored="true" multiValued="false"/>
   <field name="siteId" type="long" indexed="true" stored="true" multiValued="false"/>
   <field name="typeCode" type="text_general" indexed="true" stored="true" multiValued="false"/>
   <field name="createDate" type="date" indexed="true" stored="true" />
   <field name="typeId" type="long" indexed="true" stored="true" multiValued="false"/>

如果希望某一字段调用另外一个或者几个字段的内容,可以用到,dest是你要复制的对象,source是来源

<copyField source="title" dest="titlePinyin"/>

5:开启中文分词,首先把D:\dev\solr-6.5.1\solr-6.5.1\contrib\analysis-extras\lucene-libs 下 的solr自带的中文分词lucene-analyzers-smartcn-6.5.1.jar放到 D:\dev\solr-6.5.1\solr-6.5.1\server\solr-webapp\webapp\WEB-INF\lib下。
并下载pinyin4j的jar包pinyin4j,放到同样的位置
在schema中增加配置:

<fieldType name="text_pinyin" class="solr.TextField" positionIncrementGap="0">
    <analyzer type="index">
      <tokenizer class="solr.HMMChineseTokenizerFactory"/>
      <filter class="com.shentong.search.analyzers.PinyinTransformTokenFilterFactory" minTermLenght="2" />
        <filter class="com.shentong.search.analyzers.PinyinNGramTokenFilterFactory" minGram="1" maxGram="20" />
    </analyzer>
    <analyzer type="query">
       <tokenizer class="solr.HMMChineseTokenizerFactory"/>
       <filter class="com.shentong.search.analyzers.PinyinTransformTokenFilterFactory" minTermLenght="2" />
        <filter class="com.shentong.search.analyzers.PinyinNGramTokenFilterFactory" minGram="1" maxGram="20" />
    </analyzer>
</fieldType>

全部配置完毕,重启solr即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值