IndexTank - 如何确定查询结果的优先级
使用 indextank
rubygem,如果我索引这样的帖子,
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的评分函数 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.