Reputation: 23
I have a string field for 'title' that I want to sort alphabetically. I use Solr 4.10.2 for search and sort. Since strFields are case-sensitive by default, I am noticing that Solr is sorting my titles via ASCII sort (capital letters have priority over lowercase letters) and not alphabetically.
Mathematics: Introduction to Algebra
Mathematics: an introduction
Mathematics: an introduction
Mathematics: Introduction to Algebra
<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="string" stored="false" type="string_ci" multiValued="false" indexed="true"/>
Even after restarting Solr, reindexing, the sort is still ASCII sort
Upvotes: 1
Views: 2390
Reputation: 16035
The field must be lowercased at index time.
Remove the type
attribute in your definition so that it applies for both indexing and queries :
<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
If you want distinct analyzers for each phase, include two <analyzer>
definitions distinguished with the type attribute "index"
and "query"
.
Upvotes: 1