Reputation: 23
I have been searching this a lot, but everything I do, does not seem to work, I tried,
cat: wolf; category desc
cat: wolf; sort category desc
$query->setQuery("cat: wolf")->sort("category desc");
I cannot sort the results, I have no idea what to do.
Upvotes: 2
Views: 6615
Reputation: 2334
Hi i also face same issue in solr V 8.6.1
<fieldType name="lowercase2" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
</analyzer>
</fieldType>
<field name="top_cat_en_US" type="lowercase2" indexed="true" stored="true"/>
Upvotes: 1
Reputation: 52779
Sorting doesn't work well on multivalued and tokenized fields.
Sorting can be done on the "score" of the document, or on any multiValued="false" indexed="true" field provided that field is either non-tokenized (ie: has no Analyzer) or uses an Analyzer that only produces a single Term (ie: uses the KeywordTokenizer)
Use string as the field type (or KeywordTokenizer with lowercase filters and ascii filters applied) and copy the category field into the new field.
<field name="category_sort" type="string" indexed="true" stored="false"/>
<copyField source="category" dest="category_sort" />
Upvotes: 4