Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boosting boolean fields in Solr

Tags:

sorting

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
  • 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!

like image 868
Mun Avatar asked Apr 11 '12 20:04

Mun


People also ask

What is boosting in SOLR?

The process of giving higher relevance to a set of documents over others is called boosting, Solr support at least four ways of changing the boost factors of the documents: By boosting terms q=black^2.0 .

What is FL in Solr query?

The fl parameter limits the information included in a query response to a specified list of fields. The fields need to either be stored="true" or docValues="true"` . ` The field list can be specified as a space-separated or comma-separated list of field names.

What are wildcard search parameters SOLR?

Wildcards, * , can also be used for either or both endpoints to specify an open-ended range query. This is a divergence from Lucene's Classic Query Parser. field:[* TO 100] finds all field values less than or equal to 100. field:[100 TO *] finds all field values greater than or equal to 100.

What is DisMax in SOLR?

The DisMax query parser is designed to process simple phrases (without complex syntax) entered by users and to search for individual terms across several fields using different weighting (boosts) based on the significance of each field.


1 Answers

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,

  • 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 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).

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.

like image 134
jpountz Avatar answered Sep 19 '22 04:09

jpountz