apache - 按相关性分数的 SOLR 搜索过滤器

标签 apache search solr full-text-search search-engine

所以每个 SOLR 搜索结果都有自己的相关性分数:

https://wiki.apache.org/solr/SolrRelevancyFAQ

"How can I see the relevancy scores for search results

Request that the pseudo-field named "score" be returned by adding it to the fl (field list) parameter. The "score" will then appear along with the stored fields in returned documents. q=Justice League&fl=*,score"



我的问题是……是否可以通过此相关性分数过滤 SOLR 结果?

例如。执行以下性质的查询
Search for keyword "LOL" and only fetch documents whose relevancy score > 50

如果可能,您将如何在语法上指定此查询?

最佳答案

我花了几个小时试图过滤掉相关性分数为 0 的值。我找不到任何直接的方法来做到这一点。我最终通过将查询函数分配给本地参数的解决方法来完成此操作。我在查询 ("q=") 和过滤器查询 ("fq=") 中都调用了这个本地参数。
例子
假设您有如下查询:

q={!func}sum(*your arguments*)
首先,让函数组件成为它自己的参数:
q={!func}$localParam
&localParam={!func}sum(*your arguments*)
现在只返回分数在 1 到 10 之间的结果,只需在该 localParam 上添加一个过滤查询:
q={!func}$localParam
&localParam={!func}sum(*your arguments*)
&fq={!frange l=1 u=10 inclusive=true}$localParam

关于apache - 按相关性分数的 SOLR 搜索过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25553516/

相关文章:

python - .htaccess 与 python 脚本

java - 基于 Solr 规则的提升

Apache 2.4.7 重写规则

java - 递归名称搜索

database - 如何通过不确定的日期范围在 SQLite 数据库中搜索纪元时间戳?

arrays - in 的排序版本

ruby-on-rails - Sunspot Rails :text an :string type fields之间的区别

SolrSynonymParser 两行 "Equivalent synonyms"中的一个单词

linux - Apache2 - 添加子域时遇到问题

apache - 前面的tomcat集群apache - 如何负载均衡?