【问题标题】:Apache Solr sort based on score and fieldn values基于分数和字段值的 Apache Solr 排序
【发布时间】:2019-07-03 18:02:50
【问题描述】:

我使用了以下请求

http://localhost:8983/solr/test6/select?q=*:*&sort=product(score,hits)%20desc

根据 Apache Solr 确定的相关性分数乘以一个称为命中(整数)的字段对结果进行排序。

但是,我收到以下错误消息:

{   "responseHeader":{
    "status":400,
    "QTime":0,
    "params":{
      "q":"*:*",
      "sort":"product(score,hits) desc"}},   "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"sort param could not be parsed as a query, and is not a field that exists in the index: product(score,hits)",
    "code":400}}

为什么sort在以下情况下不能正确输入函数值:

http://localhost:8983/solr/test6/select?q=*:*&sort=score%20desc

http://localhost:8983/solr/test6/select?q=*:*&sort=hits%20desc

在不应用函数时工作?

注意http://localhost:8983/solr/test6/select?q=*:*&sort=product(hits,2)%20desc 我在其中添加 product() 函数也返回相同的错误消息。

【问题讨论】:

    标签: apache sorting search solr field


    【解决方案1】:

    score 值并不是真正的字段 - 因此您不能在排序子句中使用函数来操作它。

    相反,您可以通过 boost(如果您使用 edismax)使用乘法提升来实现您想要的:&boost=hits。您可能希望使用log(hits) 或类似的东西(例如recip)来避免因点击次数的微小变化而导致得分的巨大差异。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-13
      • 1970-01-01
      • 2018-03-08
      • 1970-01-01
      • 1970-01-01
      • 2017-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多