在Solr中增强布尔字段 [英] Boosting boolean fields in Solr

查看:98
本文介绍了在Solr中增强布尔字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在Solr中增强布尔字段,使其获得更高的分数?

Is it possible to boost boolean fields in Solr so that they receive a higher score?

我们有一个看起来像这样的索引:

We've got an index which looks a bit like this:

  • document_id
  • 标题
  • 说明
  • 关键字
  • 已接受审核

搜索时,应将已审阅的文档(即is_reviewed = true)比未审阅的文档加权更重,而不是完全排除它们.

When searching, documents that have been reviewed (ie. is_reviewed = true) should be weighted more heavily than those that haven't, rather than exclude them completely.

使用is_review:true^100似乎无效,并且排除了未审核的项目,而不仅仅是给它们较低的权重.如果有其他方法可以实现?谢谢!

Using is_review:true^100 doesn't seem to work, and excludes unreviewed items instead of just giving them a lower weighting. If there a different way this can be achieved? Thanks!

推荐答案

某些查询解析器具有专门用于这种用法的功能.例如,dismax查询解析器具有 boost查询bq 允许您通过将查询的子句添加到原始查询中来增强与查询匹配的文档.还有一个 boost函数bf ,它可以使分数相乘通过功能的结果.例如,使用is_review作为此bf参数,

Some query parsers have a feature dedicated to this kind of usage. For example, the dismax query parser has a boost query bq which allows you to boost documents which match a query by adding its clauses to the original query. There is also a boost function bf which allows you to multiply scores by the result of a function. For example, using is_review as this bf parameter,

  • 每个未定义is_review字段的文档的分数将乘以0.
  • 每个文档的分数,以便将is_review = false乘以一.
  • is_review = true的每个文档的分数将乘以2.
  • the score of every document whose is_review field is undefined will be multiplied by 0.
  • the score of every document so that is_review=false will be multiplied by one.
  • the score of every documentso that is_review=true will be multiplied by two.

is_review:true^100不应排除未审阅的项目.查询运算符.在这种情况下,您可以尝试将is_review:true^100替换为(is_review:true^100 OR is_review:false^0).

is_review:true^100 shouldn't exclude non reviewed items unless you are using AND as the default query operator. In this case, you could try to replace is_review:true^100 by (is_review:true^100 OR is_review:false^0).

如果您对dismax查询解析器的增强功能感兴趣,但希望坚持使用默认查询解析器,则可以使用

If you are interested in the boost feature of the dismax query parser but would like to stick to the default query parser, you can use the boost query parser which will allow you to multiply the scores of any query with any function.

这篇关于在Solr中增强布尔字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆