如何使用solrnet在solr中使字段搜索不区分大小写

时间:2012-04-18 08:32:44

标签: solr solrnet

在solr架构中,我有以下字段

<field name="Company" type="string" indexed="true" stored="true"/>

和字段类型为

<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>

        <fieldType name="text" class="solr.TextField" positionIncrementGap="100"><analyzer type="index"><tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
    </analyzer>
    <analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/><filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
    </analyzer>
    </fieldType>

当我在此字段上搜索时,它区分大小写

我如何才能使此字段搜索不区分大小写?

感谢。

1 个答案:

答案 0 :(得分:3)

一种方法是将相关字段转换为小写的复制字段。仅用于搜索。一篇有类似问题的帖子:)

How to create a case insensitive copy of a string field in SOLR?