Configuration of Solr(5.2.0) 2

Some tips or notes:
  • To make the changes of the configuration files effective, the Solr search engine needs to be rebooted.
  • To delete all the indexed data from the yourcorename of Solr, run ' bin/post -c yourcorename -d "<delete><query>*:*</query></delete>" '.
  • To delete an existed core, run' bin/post delete -c yourcorename '.
  • To create a new core, run ' bin/post create -c yourcorename '.
  • To index a file, run ' bin/post -c yourcorename filepath '.
Add stopwords:
Following the configuration of 1.
Go to directory /server/solr/conf, add stopwords to stopwords.txt as schema.xml has the following content:

    <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="true">
      <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
        <!-- in this example, we will only use synonyms at query time
        <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
        -->
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>

Create another fieldType to add flexibility to use a different stopwords list. Add the following content to schema.xml.
    <!-- Create another fieldType to add flexibility to use a different stopwords list -->
    <fieldType name="text_alterstopw" class="solr.TextField" positionIncrementGap="100" multiValued="true">
      <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="alterstopwords.txt" />
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="alterstopwords.txt" />
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>
and create an empty text file 'alterstopwords.txt' in /server/solr/conf. You can add any content to this file.

To use the type 'text_alterstopw', a copyField needs to be created. For example, I want to create a field to search the content of my document with no stopwords filtered. Leave the file 'alterstopwords.txt' empty, and add the following line to schema.xml.
<field name="content_copy" type="text_alterstopw" indexed="true" stored="false" multiValued="false"/>
<copyField source="content" dest="content_copy"/>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值