user1788154
user1788154

Reputation: 21

case insensitive search for solr facets but actual value needs to be shown

I want to get case insensitive search for facets in solr.Below is my facet field and field type declaration.

//stored=true to get actual values

<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>

<dynamicField name="facet_*" type="c_text" multiValued="true"                 indexed="true" stored="true" omitNorms="true"/>

The queries are getting resolved properly and in document values shown are in actual case but in facet results names are being shown in lower case only like below.

facet_color_family: {
**blue**: 41,                             
navy blue: 7
}

Actual values before indexing were Blue and Navy Blue. Note that when they are shown in documents values are proper like below.

 "facet_color_family": [
          "**Blue**"
        ],

Upvotes: 0

Views: 3106

Answers (2)

saurabh
saurabh

Reputation: 2459

remove LowerCaseFilter or use plain String as field type. then for facet search you can use facet.contains=keyword and face.contains.ignoreCase=true.

Upvotes: 1

aalbahem
aalbahem

Reputation: 782

My suggestion is to have two fields. One with lower casing and the other without it. Then search using the lowercase field and return the facet using the field without the lowercase processing. To save space, you should only index the fields. I do not think you actually need to store them for facet filtering.

Upvotes: 0

Related Questions