简体   繁体   中英

Solr Case-insensitive Query

I need to filter a query (fq) in a case-insensitive way. All the solutions I see online has to do with editing the file schema.xml.

However, I don't have this file since I'm using a schema less Solr (data-driven config set).

How can I still achieve this result? Many thanks!

As you are using the dynamicField defined in the managed-schema file . You are using the pattern

as your field also ends with *_ss pattern as name_ss . Here as you see the field *_ss has the type strings and these are not analysed or rather indexed as it is.

I suggest you to use below dynamicField

<dynamicField name="*_txt" type="text_general" indexed="true" stored="true"/>

Here the text_general type is built like below in the managed-schema file

 <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
        <filter class="solr.LowerCaseFilterFactory"/>
        <charFilter class="solr.PatternReplaceCharFilterFactory"
         pattern="-" replacement=""/>
        <charFilter class="solr.PatternReplaceCharFilterFactory"
         pattern="." replacement=""/>
   </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>

So you will have the field as name_txt .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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