简体   繁体   English

Solr:按分数和 int 字段值排序

[英]Solr: Sort by score & an int field value

I need to sort documents returned in order of (descending) score & (descending) value of an int field within the document.我需要按文档中 int 字段的(降序)分数和(降序)值的顺序对返回的文档进行排序。 How do I ensure proper sort order as well as good performance ?如何确保正确的排序顺序以及良好的性能?

I don't need the sort-order defined by sort=score desc,intField desc .我不需要sort=score desc,intField desc定义的sort=score desc,intField desc顺序。 The sort order needs to be somewhat like what will be delivered using product function of score * fieldVal as effective score for sort order.排序顺序需要有点像使用score * fieldVal产品函数作为排序顺序的有效分数将交付的内容。 But I don't need exact product for sorting.但我不需要精确的产品进行排序。 Approximations are ok, & this is just to roughly define the sort order I need.近似值没问题,这只是粗略地定义我需要的排序顺序。

I can see a few possible ways to accomplish this:我可以看到几种可能的方法来实现这一点:

1. Use a customized function of score for sort 1.使用自定义的score功能进行sort

2. Use query time boost to increase the score using the int field value for boost 2.使用查询时间boost提高分数使用int字段值进行boost

I'm new to Solr & don't understand the performance implications of each of above case.我是 Solr 的新手,不了解上述每种情况的性能影响。 Also, don't know if there are other better ways to accomplish what I am trying to do.另外,不知道是否有其他更好的方法来完成我正在尝试做的事情。 So how do I build performance friendly query to achieve this sort order ?那么如何构建性能友好的查询来实现这种排序顺序呢?

Have a look at solr function queries看看 solr 函数查询

https://lucene.apache.org/solr/guide/6_6/function-queries.html#FunctionQueries-SortByFunction https://lucene.apache.org/solr/guide/6_6/function-queries.html#FunctionQueries-SortByFunction

Example: &sort=product(score, fieldVal)示例:&sort=product(score, fieldVal)

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

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