I Have a Solr index that stores Price in a multivalued field for each Product.
I need to sort the result set by Price where the Price is Low to high and High to Low.
I try to use sorting on Price it's showing Error You can't sort on multivalued=True fields.
below is my solr XML
<arr name="sellprice">
<float>195.0</float>
<float>136.5</float>
<float>10.0</float>
</arr>
in schema.xml
<field name="sellprice" type="float" indexed="true" stored="true" multiValued="true"/>
In C# Code
ISolrQueryResults<ProductTest2> powerArticles = solr.Query(new
SolrQuery("WebCategory_Id:10") && new SolrQueryInList("FilterID",
146), new QueryOptions { FilterQueries = new[] { new
SolrQueryByRange<decimal>("sellprice", 10, 40) }, OrderBy = new[] {
new SolrNet.SortOrder(sellprice, desc) } });
Can somebody explain with some good example?
Sorting on multivalued fields does not work fine with Solr.
Documentation
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)
When you want to sort the products from low to high or high to low, what price will Solr pick ? As from the example you have a Sell price of 0 as well as 195 ?
The function queries also do not allow to use max or min on the multivalued fields.
The option you have to save the highest and lowest sell price as single valued fields, and use those fields for sorting.
highest_sell_price=195
lowest_sell_price=0
and use these fields for sorting.