Solr不区分大小写的搜索

时间:2015-09-14 18:33:59

标签: search solr schema

我有以下架构:

<?xml version="1.0" encoding="UTF-8" ?>
<schema name="customers" version="1.5">
    <types>
        <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
        <fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
            <analyzer type="query">
                <tokenizer class="solr.KeywordTokenizerFactory"/>
                <filter class="solr.LowerCaseFilterFactory"/>
            </analyzer>
            <analyzer type="index">
                <tokenizer class="solr.KeywordTokenizerFactory"/>
                <filter class="solr.LowerCaseFilterFactory"/>
            </analyzer>
        </fieldType>
    </types>
    <fields>
        <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
        <field name="companyname" type="string_ci" indexed="true" stored="true" required="true" multiValued="false" />
        <field name="contactname" type="string" indexed="true" stored="true" required="true" multiValued="false" />
        <field name="contacttitle" type="string" indexed="true" stored="true" required="true" multiValued="false" />
        <field name="address" type="string" indexed="true" stored="true" required="true" multiValued="false" />
        <field name="city" type="string" indexed="true" stored="true" required="true" multiValued="false" />
        <field name="postalcode" type="string" indexed="true" stored="true" required="false" multiValued="false" />
        <field name="country" type="string" indexed="true" stored="true" required="true" multiValued="false" />
        <field name="phone" type="string" indexed="true" stored="true" required="true" multiValued="false" />
        <field name="fax" type="string" indexed="true" stored="true" multiValued="false" />
        <field name="region" type="string" indexed="true" stored="true" multiValued="false"/>
    </fields>
    <uniqueKey>id</uniqueKey>
</schema>

但是,我无法在companyname字段上搜索不区分大小写的方法。我使用了http://northwind.servicestack.net/customers.json处提供的示例数据。

当前版本:3.5.0

我尝试过混合和匹配不同的组合,似乎都没有效果。有些专家,请指教。

1 个答案:

答案 0 :(得分:1)

您可以为您的字段&#34; companyname&#34;

尝试以下字段
<fieldType name="c_text" class="solr.TextField">
    <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>

    <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
</fieldType>



<field name="companyname" type="c_text" indexed="true" stored="true" required="true" multiValued="false" />