Arbejdsglæde
Arbejdsglæde

Reputation: 14088

Solr Facet and Tokenizer

I have solr array field that could contain string with some separate words as a one value, for example ["Super Ball", "BlaBla", "Info"]. I need to see all those 3 values as an facet values and have case insensitive search by fields as well.

If I use next field type setting I see 3 values in facet but case insensitive search doesn't work.

<fieldType name="myLower" class="solr.TextField" positionIncrementGap="100">
     <analyzer type="index"> 
        <tokenizer class="solr.KeywordTokenizerFactory"/>    
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">     
        <tokenizer class="solr.KeywordTokenizerFactory"/>       
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
   </fieldType>

if I use <tokenizer class="solr.StandardTokenizerFactory"/> I can use lower case search, but I see 4 facet values, becourse StandardTokenizerFactory splits "Super Ball" to 2 words.

How to manage such case ?

Upvotes: 0

Views: 587

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

Use two separate fields. One for faceting and one for searching - they're different operations and different field definitions will suite each better.

Use <copyField source="searchfield" dest="facetfield" maxChars="30000" /> to copy the contents you're sending into your searchfield to a dedicated faceting field. Use the facetfield (with either keywordtokenizer + lowercasing or just a string field if you want to keep the case intact) for faceting, and perform searches against the searchfield. The facetfield will also be used when you're applying fq filters when the user has picked a facet for further filtering.

Upvotes: 2

Related Questions