Solr不区分大小写索引和搜索?

时间:2016-02-11 06:28:30

标签: solr solrj solrcloud

目前我正在使用solr5.4.1。虽然索引工作正常,但根据案例搜索数据不敏感。

假设我创建了包含代码[“AnandProjectp1”,“AnandProjectp2”,“AnandProjectp3”]和名称的项目 [ “PROJECT1”, “Project2的”, “项目3”]

但是当我搜索以#开头的代码时 q = project_code:a *或project_name:p *我得到0结果。

我的Schema.xml是`

<field name="company_id" type="tint" stored="true" positionIncrementGap="100"/>
<field name="company_public_id" type="string" stored="true" positionIncrementGap="100"/>
<field name="company_name" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="company_description" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="user_id" type="tint" stored="true" positionIncrementGap="100"/>
<field name="user_company_id" type="string" stored="true" positionIncrementGap="100"/>
<field name="user_first_name" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="user_last_name" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="user_email_id" type="string" indexed="true" stored="true" positionIncrementGap="100" sortMissingLast="true" omitNorms="true" ignoreCase="true"/>
<field name="user_code" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="user_public_id" type="String" stored="true" positionIncrementGap="100"/>
<field name="project_id" type="tint" stored="true" positionIncrementGap="100"/>
<field name="project_company_id" type="tint" stored="true" positionIncrementGap="100"/>
<field name="project_code" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="project_name" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="project_description" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="project_public_id" type="string" stored="true" positionIncrementGap="100"/>
<field name="template_id" type="tint" stored="true" positionIncrementGap="100"/>
<field name="template_company_id" type="tint" stored="true" positionIncrementGap="100"/>
<field name="template_public_id" type="string" stored="true" positionIncrementGap="100"/>
<field name="template_description" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="template_name" type="text_en_splitting" indexed="true" stored="true" positionIncrementGap="100"/>




<fieldType name="string" class="solr.StrField">
    <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>                                       
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>                          
    </analyzer>
</fieldType>
<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>   
<fieldType name="text_en_splitting" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>        
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>        
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>        
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>        
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
</fieldType>    


`

模式取自示例中给出的示例schema.xml

1 个答案:

答案 0 :(得分:0)

您可以尝试按照fieldType

<fieldType name="wildCardType" class="solr.TextField" sortMissingLast="true" omitNorms="true" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="50"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

并且还要

<field name="project_code" type="wildCardType" indexed="true" stored="true" positionIncrementGap="100"/>
<field name="project_name" type="wildCardType" indexed="true" stored="true" positionIncrementGap="100"/>