IndexTank - 如何确定查询结果的优先级

发布于 2025-01-03 18:36:18 字数 372 浏览 2 评论 0原文

使用 indextank ruby​​gem,如果我索引这样的帖子,

indexes.document(post.id).add({:title=> post.title, :text=> post.body})

我的查询应该是什么样子,以便在 body 匹配之前返回 title 匹配。执行此操作:

indexes.search("title:#{query} OR text:#{query}", :snippet=> :text)

返回按从最新到最旧排序的所有匹配项。

谢谢。

Using the indextank rubygem, if I index a post like this

indexes.document(post.id).add({:title=> post.title, :text=> post.body})

What should my query look like such that the title matches are returned before the body matches. Doing this:

indexes.search("title:#{query} OR text:#{query}", :snippet=> :text)

returns all matches ordered from newest to oldest.

Thank you.

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

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

发布评论

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

评论(1

怪我入戏太深 2025-01-10 18:36:18

您的评分函数 0 定义为什么?默认情况下,它是“-age”,意思是最近的在前。对于文本相关性,可以将评分函数替换为“rel”,即文本相关性。

我不知道有什么方法可以确保每个标题匹配都高于其他标题,但是您可以通过在查询的标题部分添加“^10”来极大地“提升”标题。下面是一个示例:

title:potter^10 text:whatever

这意味着标题匹配比“text”字段的匹配高 10 倍。如有必要,您可以提高数字“10”。

What is your scoring function 0 defined as? By default, it is "-age", which means most recent first. For text relevance, you can replace scoring function with "rel", which means text relevance.

I don't know of a way to ensure that every title match is guaranteed to be above the rest, but you can "boost" the title greatly by adding "^10" to your title part of the query. Here's an example:

title:potter^10 text:whatever

This means title matches are 10 times higher than matches for the "text" field. You can raise the number "10" higher if necessary.

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