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
- title
- description
- keywords
- is_reviewed
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.
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!
Some query parsers have a feature dedicated to this kind of usage. For example, the dismax query parser has a boost query
bqwhich allows you to boost documents which match a query by adding its clauses to the original query. There is also a boost functionbfwhich allows you to multiply scores by the result of a function. For example, usingis_reviewas thisbfparameter,is_reviewfield is undefined will be multiplied by 0.is_review=falsewill be multiplied by one.is_review=truewill be multiplied by two.is_review:true^100shouldn’t exclude non reviewed items unless you are usingANDas the default query operator. In this case, you could try to replaceis_review:true^100by(is_review:true^100 OR is_review:false^0).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.