Mailing List Archive

[patch] bug with boosts in parsed queries
Hi,

Following up a related post I made on lucene-user yesterday, I've
tracked down what I consider to be a bug in the Query parser relating to
boosting boolean queries.

In short, I think it's reasonable for a user to want to boost all the
terms within a set of parentheses like this:

(fred jim bob)^2.0

However, this fails with the current query parser - the boost factor is
silently ignored.

Please find attached a patch that adds two assertions to the query
parser test, demonstrating the above problem. The patch also includes a
minor change to QueryParser.jj to fix the problem and a tweak to
BooleanQuery.toString() to help test it.

Regards,

--
Lee Mallabone.
Granta Design Ltd.
Re: [patch] bug with boosts in parsed queries [ In reply to ]
This fixes the query parser, but, unfortunately, the problem is deeper.
BooleanQuery does not implement boosting. This could be fixed too,
but, for now, the easiest thing to do is simply to boost each term
within the boolean query.

Doug


--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>
Re: [patch] bug with boosts in parsed queries [ In reply to ]
On Fri, 2002-09-06 at 20:11, Doug Cutting wrote:
> This fixes the query parser, but, unfortunately, the problem is deeper.
> BooleanQuery does not implement boosting. This could be fixed too,
> but, for now, the easiest thing to do is simply to boost each term
> within the boolean query.

Ah. That *would* explain why further tests I made on a real index looked
like no weighting was occuring on boolean query rankings! :)

Should I update the patch for now so that BooleanQuery.setBoost() just
calls setBoost() on all its clauses?

Regards,

--
Lee Mallabone.


--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>
Re: [patch] bug with boosts in parsed queries [ In reply to ]
Lee Mallabone wrote:
> Should I update the patch for now so that BooleanQuery.setBoost() just
> calls setBoost() on all its clauses?

That only works if you call setBoost() after all of the clauses have
been added, which is a little fragile. So you'd also need to boost new
clauses as they're added. Also, what happens when a clause already has
a boost that's not equal to 1? Should setBoost() then set each clause's
boost to the product of its current boost and the supplied boost?

So yes, its possible to fix this way, if a little complex. Things would
be simpler if BooleanQuery just multiplied its boost into the scores.

Doug


--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>