Yoaz Menda
Yoaz Menda

Reputation: 1696

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!

Upvotes: 1

Views: 2642

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

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.

Upvotes: 4

Related Questions