1
votes

I'm having an issue with Lucene's Term [Boosting][1] query syntax, specifically in Ruby on Rails via the sunspot_rails gem. This is whereby you can specify the weight of a specific term during a query, and is not related to the weighting of a particular field.

The HTML query generated by sunspot uses the qf parameter to specify the fields to be searched as configured, and the q parameter for the query itself. When the caret is added to a search term to specify a boost (i.e. q=searchterm^5) it returns no results, even though results would be returned without the boost term.

If, on the other hand, I create an HTTP query manually and manually specify the field to search (q=title_texts:searchterm^5), results are returned and scores seem affected by the boost.

In short, it appears as though query term boosting doesn't work in conjunction with fields specified with qf.

My application calls for search across several fields, using the respective boosts associated to those fields, conditionally in turn with boosting on individual terms of a query.

Any insight?

[1]: http://lucene.apache.org/java/2_9_1/queryparsersyntax.html#Boosting a Term

2

2 Answers

2
votes

Sunspot uses the dismax parser for fulltext search, which eschews the usual Lucene query syntax in favor of a limited (but user-input-friendly) query syntax combined with a set of additional parameters (such as qf) that can be constructed by the client application to tune how search works. Sunspot provides support for per-field boost using the boost_fields method in the fulltext DSL:

http://outoftime.github.com/sunspot/docs/classes/Sunspot/DSL/Fulltext.html#M000129

1
votes

The solution I have found is to use DisMax, but adding the bq parameter with a boolean string with the boosted terms therein.