0

Im using the solr engine to an e-commerce website I have store the search tags as a sting in a single field as below, I need to get convert that field to case insensitive.I tried to apply the lowercase filter factory and it goes not work for the field

<field name="tags" type="string" multiValued="true" indexed="true" stored="true"/>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" docValues="true"/>
  <analyzer>
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>

Sample of the field

"tags":["Property",
          "House",
          "Land",
          "Home",
          "House For Sale",
          "Property For Sale",
          "Land For Sale",
          "Prime property for sale",
          "Prime property for sale in Colombo 03"],

1 Answers1

1

You have defined your field as StrField. String fields can't have analysis chains attached. You have to change it to a TextField:

<fieldType name="string" class="solr.TextField" sortMissingLast="true" docValues="true"/>
  <analyzer>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

However, I'd recommend using a different name than string for the field, since the string field type is expected to work in a particular way (such as when used for id fields, etc.). Instead, use something describing what it does, such as string_caseinsensitive.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • HI @MatsLindh I need to get the exact match from the tags field, that's why I have used the string field – sarin Wickramasinghe Feb 12 '21 at 14:45
  • 1
    So do you need _exact matches_ or do you need _case insensitive_ matches? They're not the same. You can't have analysis chains attached to a `string` field, but a text field with a keyword tokenizer and a lower case filter will in effect be a case insensitive string field. You'll might want to use a `copyField` instruction as well, so that you can use one for generating the facet (which maintains case) and one for filtering (which is case insensitive), it depends on your exact use case. – MatsLindh Feb 12 '21 at 15:07