Goal
Provide end users with the ability to toggle between case-sensitive and case-insensitive search modes within a Fusion application using Solr.
Environment
Fusion 4.x and 5.x (self-hosted and managed)
Solr 7.7.3 and above
Applicable to environments where Appkit, advanced search interfaces, or custom query pipelines are used
Guide
To enable both case-sensitive and case-insensitive search within the same Fusion collection, the underlying Solr schema and index pipeline must support both modes through duplicated fields or selective indexing. Below are recommended implementation options. There are other implementation possibilities that will work just as well, but they will still have to meet the goal of each step.
Step 1: Index into both case-sensitive and case-insensitive fields
Use Fusion’s index pipeline to duplicate content into two separate Solr fields:
One field using a case-insensitive analyzer (e.g.,
text_general)One field using a case-sensitive analyzer (e.g.,
stringor a custom fieldType with no lowercasing)
Step 1: Define case-sensitive and case-insensitive fields in the Solr schema:
<field name="title_case_insensitive" type="text_general" indexed="true" stored="true"/>
<field name="title_case_sensitive" type="text_general_case_sensitive" indexed="true" stored="true"/>Ensure the custom field type does not include a lowercase filter:
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
<fieldType class="solr.TextField" multiValued="true" name="text_general_case_sensitive" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<!-- in this example, we will comment out the filter to make field case sensitive
<filter class="solr.LowerCaseFilterFactory"/>
-->
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<!-- in this example, we will comment out the filter to make field case sensitive
<filter class="solr.LowerCaseFilterFactory"/>
-->
</analyzer>
</fieldType>Step 2: Duplicate field values in the index pipeline
Add a Field Mapping stage to populate both fields, by doing a "copy" from one field to the other.
Step 3: Apply boosting logic to prioritize case-sensitive matches
For strict toggle implementation, adjust the queryFields to only use the one version of the field. This is most easily done by having duplicate Query Fields stages, each with a condition that will only allow the stage to execute when it's associated toggle is set.
Query Field documentation - https://doc.lucidworks.com/docs/5.9/fusion/reference/config-ref/pipeline-stages/query-stages/search-fields-query-stage
For better ranking without requiring a strict toggle, you can always query both fields and boost the case-sensitive field.
In your query pipeline, adjust the queryFields parameter to include both fields, but boost the case sensitive one higher:
"queryFields": ["title_case_sensitive^5", "title_case_insensitive"]This ensures that exact-case matches appear higher in results, while still allowing case-insensitive matches into the result set.
Step 4: Implement a user toggle in the UI
Provide a checkbox or toggle in the UI that adjusts the fields being queried depending on user preference.
Case-sensitive ON → Query only the case-sensitive fields
Case-sensitive OFF → Query only the case-insensitive fields
Summary
By indexing content into both case-sensitive and case-insensitive fields and controlling which fields are queried at runtime, you can give users flexible search behavior without requiring multiple collections. Boosting strategies or field-level toggles allow further refinement to improve relevancy or control precision.