apache - 基于分数和字段值的 Apache Solr 排序
问题描述
我使用了以下请求
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() 函数的地方也返回相同的错误消息。
解决方案
该score
值并不是真正的字段 - 因此您不能使用函数在排序子句中对其进行操作。
相反,您可以使用乘法提升boost
(如果您使用的是 edismax)来实现您想要的:&boost=hits
. 您可能想要使用log(hits)
或类似的东西(recip
例如)来避免因点击次数的微小变化而导致得分的巨大差异。
推荐阅读
- docker - 更新 Strapi Docker package.json
- python - 为什么我使用 scapy.sniff() 函数试图嗅探打开的网站的流量时得到这个奇怪的输出?
- javascript - 如何在 PHP 中检索使用 fetch() 从 React js 发送的数据?
- reactjs - 从父 React 组件状态继承的 Formik initialValues 的异步更新(利用 useEffect 挂钩?)
- c++ - AVL 树旋转函数正在丢失数据
- javascript - chrome打开时如何在chrome扩展中持续获取网络摄像头提要?
- javascript - 使用引导程序进行模态触发,因为它是在聚焦后触发的
- google-cloud-platform - 关于如何在 GCP Memorystore (Redis) DB 中刷新缓存的问题
- python - Tensorflow 自定义层权重不是训练而是偏差是
- npm - 无法加载在“.eslintrc.json”中声明的插件“react”:找不到模块“eslint-plugin-react”