如何根据条件提高 Solr 搜索结果的分数?

发布于 11-17 17:22 字数 295 浏览 6 评论 0原文

背景:

1 - 我使用 WebSolr 进行此搜索。 2 - 我有两个字段存储在 websolr 中 - 名称和 ID。

我想根据名称搜索这些条目并根据此标准提高搜索分数:

if id in [x1,x2..xN] then +2
if id in [y1,y2..yN] then +1
else +0

根据我的研究,答案如下 - 函数查询,或 - DisMaxQParser

我已经查看了文档,但在我看来它不是很全面。

任何帮助表示赞赏。

Background:

1 - I'm using WebSolr for this search.
2 - I have two fields stored in websolr - name and id.

I want to search for these entries based on name AND boost the search score based on this criteria:

if id in [x1,x2..xN] then +2
if id in [y1,y2..yN] then +1
else +0

From my research, the answer lies in the following
- Function query, or
- DisMaxQParser

I have looked at the documentation but IMO its not very comprehensive.

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情泪▽动烟2024-11-24 17:22:04

您可以使用增强功能。尝试像这样的查询

name:searchString AND ( id:[x1 TO xN] ^2 OR id:[y1 TO yN]^1)

You can use boosts. Try a query like

name:searchString AND ( id:[x1 TO xN] ^2 OR id:[y1 TO yN]^1)
晨光如昨2024-11-24 17:22:04

除了 hkn 的方法之外,您还可以使用 DisMax 查询解析器 增强查询:(

q=queryString
&defType=dismax
&qf=…
&bq=id:[x1+TO+xN]^3
&bq=id:[y1+TO+yN]^2

未经测试,但应该传达这个想法。)

In addition to hkn's approach, you could also use DisMax query parser boost queries:

q=queryString
&defType=dismax
&qf=…
&bq=id:[x1+TO+xN]^3
&bq=id:[y1+TO+yN]^2

(Untested, but should convey the idea.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文