如何为思考狮身人面像的关键字添加权重
我做了这样的搜索,
` Comment.search "aabbb "`
我想得到也包含“ab”的结果。 所以我就这样做了:
` Comment.search "aabbb ab"`
但是我发现结果aabbb
和ab
是混合的,事实上,我想让结果匹配aabbb
显示在ab
之前,换句话说,具有更高的优先级。
我知道狮身人面像可以增加表格字段的权重。例如,在评论名称中添加 10,在评论内容中添加 20。但是否可以增加查询工作的权重?
I did such search,
` Comment.search "aabbb "`
and I want to get the results which contain "ab" too.;
So I did that way:
` Comment.search "aabbb ab"`
but I found the results aabbb
and ab
are mixed , in fact, I want to make the results which match aabbb
shows before ab
, in other words, have a higher priority.
I know sphinx can add weight the fields of the table. for example add 10 to comments's name, 20 to comment's content. but is it possible to add weight to the query works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,这对于 sphinx 来说还不可能,但您可以通过多次添加您想要加权的关键字来在查询上添加类似的行为。
例如:
Unfortunately this is not possible with sphinx yet but you can add similar behavior on a query by adding multiple times the keyword you want to weight.
For example:
恐怕 Sphinx 无法对某些搜索短语进行加权 - 所以你想要做的事情是不可能的。
还值得注意的是,Sphinx 默认使用 AND 逻辑 - 如果您想要匹配 aabbb 或 ab 的结果,您可能需要使用 :any 匹配模式:
Sphinx has no ability to weight certain search phrases, I'm afraid - so what you're trying to do is not possible.
It's also worth noting that Sphinx uses AND logic by default - if you want results that match either aabbb OR ab, you'll probably want to use the :any match mode: