根据前 100 条记录排序 Solr

Sort Based on the top 100 records Solr

这与下面的不同:

How to sort the top 100 results of solr query based on a specific filed?

假设我的搜索条件 title:Building the Nation returns 100k 个结果。我猜 Solr 已经 returns 基于最佳匹配的数据,即最佳匹配数据将在顶部。我正在根据某些事情进行排序。在这种情况下,最后位置的记录可能排在最前面。

https://host/solr/booksCore/select?q=(title:"Building the Nation" OR title:Building the Nation OR author:"Building the Nation" OR author:Building the Nation) AND subjects:*&rows=100&sort=sales_a desc&wt=json

所以我想先搜索,然后取前100条记录,然后排序。我怎样才能使用 Solr select API?

首先 - 您正在编写的查询没有执行您可能希望它们执行的操作。 author:Building the Nationauthor 字段中搜索 Building,在默认搜索字段中搜索 theNation。在这种情况下,您可能需要 author:the author:Nation,或者将 qfedismax 查询解析器一起使用(并使用 pspf 来增强短语).

其次,如果 subjects:* 旨在匹配任何具有主题的文档,则该语法将为 subjects:[* TO *].

然后第三,到 re-rank the top N results in a query,你可以使用 rq - 重新排名查询。此查询的结果将是一组新的分数,您可以使用 reRankWeight 参数提高分数:

In the example below, the top 1000 documents matching the query "greetings" will be re-ranked using the query "(hi hello hey hiya)". The resulting scores for each of those 1000 documents will be 3 times their score from the "(hi hello hey hiya)", plus the score from the original "greetings" query:

q=greetings&rq={!rerank reRankQuery=$rqq reRankDocs=1000 reRankWeight=3}&rqq=(hi+hello+hey+hiya)

您可以使用_val_直接指定一个数值作为文档的分数,有效地按该值反向排序。