有什么方法可以在 solr 中实现自定义( index/count 除外)方面值排序?

Is there any way to implement customized (except index/count ) facet values sorting in solr?

假设我们正在使用 iphone 进行搜索,并且在品牌方面我们得到以下方面 1)安泽 2)苹果 3)阿拉瑞 4)炮台 5)每日对象

它是按字母顺序排列的。但是我们想根据 每个品牌的一些定制分数。 solr faceting 中是否有任何功能可以满足上述要求?

如果我们有针对每个品牌分面值的分数,那么有没有办法在 solr 端执行分面?

目前,solr 只有两个 facet.sort 选项,即索引和计数。 除了索引和计数之外,我们还想合并其他排序选项。 请提出建议。

既然你在谈论字段的聚合,你可以使用 Facet JSON API:

给出的示例可以满足您的要求:

{
  categories:{
    type : terms      // terms facet creates a bucket for each indexed term in the field
    field : cat,
    sort : "x desc",  // can also use sort:{x:desc}
    facet : {
      x : "avg(price)",     // x = average price for each facet bucket
      y : "max(popularity)" // y = max popularity value in each facet bucket
    }
  }
}

这汇总了该方面所有元素的平均价格,同时还按它排序 - 首先为您提供平均价格最高的类别。

可用于 facets 下聚合的受支持函数列表是 available in the reference guide:

  • sum, sum(sales), 数值求和
  • avg, avg(popularity), 数值的平均值
  • min, min(salary), 最小值
  • max, max(mul(price,popularity)), 最大值
  • 唯一,唯一(作者),唯一值的数量
  • hll,hll(作者),通过 hyper-log-log 算法进行分布式基数估计
  • percentile, percentile(salary,50,75,99,99.9),通过 t-digest 算法估计的百分位数。按此指标排序时,列出的第一个百分位数用作排序值。
  • sumsq, sumsq(rent), 字段或函数的平方和
  • 方差,wvariance(rent),数值字段或函数的方差
  • stddev, stddev(rent), 字段或函数的标准差