Solr 3.5 – Search case insensitive on a string field for exact match
Solr has by default in the schema.xml the field type “string” available.
<!-- The StrField type is not analyzed, but indexed/stored verbatim. -->
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
With this field type you can search with a string to get an exact match, instead of a contains match that the “text_general” field type will give you. However another difference is that the “text_general” field type is case insensitive by default and “string” is case sensitive.
To perform an case insensitive exact match search, you’ll have to add a custom field type in your Solr schema.xml, I called it “string_ci” (string case insensitive).
<!-- With this field type case is preserved for stored values, but a case insensitive field will
be provided to search on. Caveat: case insensitive wildcard search cannot be done since
wild card phrases bypass the query analyzer and will not be lowercased before matching
against the index. This means that the characters in wildcard phrases must be lowercase in
order to match.
-->
<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>