简体   繁体   English

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

[英]Solr case insensitive indexing and search?

Currently I am using solr5.4.1 .while Indexing is working fine, searching the data based on case -insensitive is not working. 当前,我正在使用solr5.4.1。虽然索引工作正常,但是基于不区分大小写的数据搜索不起作用。

Say I have created Projects with codes ["AnandProjectp1","AnandProjectp2","AnandProjectp3"] and names ["Project1","Project2","Project3"] 假设我已经创建了代码为[“ AnandProjectp1”,“ AnandProjectp2”,“ AnandProjectp3”]和名称为[“ Project1”,“ Project2”,“ Project3”]的项目

but when I am searching for code starting with q=project_code:a* or project_name:p* i am getting 0 results. 但是当我搜索以q = project_code:a *或project_name:p *开头的代码时,我得到0个结果。

My Schema.xml is` 我的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>    


` `

the schema was taken from the example schema.xml given in the examples 该模式取自示例中给出的示例schema.xml

ou can try by following fieldType 您可以通过遵循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>

and also chnage the 并更改

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM