在Solr中使用多值字段排序 [英] Sorting with Multivalued Field in Solr

查看:460
本文介绍了在Solr中使用多值字段排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Solr索引,将每个产品的价格存储在多值字段中.

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.

我尝试对价格使用排序,这显示了错误您无法对multivalued = True字段进行排序.

I try to use sorting on Price it's showing Error You can't sort on multivalued=True fields.

下面是我的Solr XML

below is my solr XML

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

在schema.xml中

in schema.xml

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

使用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) } });

有人可以举例说明吗?

推荐答案

在多值字段上排序不适用于Solr.

Sorting on multivalued fields does not work fine with Solr.

文档

排序可以在文档的分数"上进行,也可以在任何multiValued ="false" indexed ="true"字段上进行,只要该字段为 非令牌化(即:没有分析器)或仅使用分析器 产生一个字词(即:使用KeywordTokenizer)

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)

当您要从低到高或从高到低对产品进行分类时,Solr将选择什么价格?从该示例中,您的卖出价格为0以及195?

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 ?

函数查询也不允许在多值字段上使用max或min. /a>

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.

这篇关于在Solr中使用多值字段排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆