简体   繁体   English

在Solr中使用多值字段排序

[英]Sorting with Multivalued Field in Solr

I Have a Solr index that stores Price in a multivalued field for each Product. 我有一个Solr索引,可以在每个产品的多值字段中存储Price。

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. 我尝试使用Price它显示错误排序您无法对多值=真实字段进行排序。

below is my solr XML 下面是我的solr XML

<arr name="sellprice">
<float>195.0</float>
<float>136.5</float>
<float>10.0</float>
</arr>

in schema.xml 在schema.xml中

 <field name="sellprice" type="float" indexed="true" stored="true" multiValued="true"/>

In C# Code 在C#代码中

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. 使用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) 可以在文档的“得分”上进行排序,或者在任何multiValued =“false”indexed =“true”字段上进行排序,前提是该字段是非标记化的(即:没有分析器)或使用仅生成分析的分析器单个术语(即:使用KeywordTokenizer)

When you want to sort the products from low to high or high to low, what price will Solr pick ? 当您想要将产品从低到高或从高到低排序时,Solr选择什么价格? As from the example you have a Sell price of 0 as well as 195 ? 从示例中您的卖出价为0以及195?

The function queries also do not allow to use max or min on the multivalued fields. 函数查询也不允许在多值字段上使用max或min。

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. 并使用这些字段进行排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM