Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indexing Fields with SOLR and LowerCaseFilterFactory

Tags:

solr

facet

I have a Field defined as

<fieldType name="text_ws_lc" class="solr.TextField" positionIncrementGap="100">
  <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"/>
  </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"/>
  </analyzer>
</fieldType>

Which works fine for searching without case sensitivity on fields that are this type. However I want the original value inserted into the field NOT the lowercase value. Is it possible to remove the LowerCaseFilterFactory from the index analyzer and get this functionality? ALA

<fieldType name="text_ws_lc_std" class="solr.TextField" positionIncrementGap="100">
  <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"/>
  </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"/>
  </analyzer>
</fieldType>
like image 996
RyanFetz Avatar asked Jun 28 '10 17:06

RyanFetz


1 Answers

You should define two fields: one with the value in lower case used for searching and another one to hold the original value. You can use a copy field instruction in your schema.xml to maintain the two fields in sync.

like image 149
Pascal Dimassimo Avatar answered Sep 17 '22 15:09

Pascal Dimassimo