Ok then I'll open an issue and provide a patch. Thanks !
On Jan 15, 2008 8:18 PM, Paul Elschot <[EMAIL PROTECTED]> wrote: > Correcting myself: > > On Tuesday 15 January 2008 17:55:42 you wrote: > > Shai, > > > > I think it would be enough to add to the javadocs of BooleanQuery that > > the minimum number of SHOULD clauses is ignored when no such clauses > > are added. > > I should have looked at the code of BooleanScorer2 before answering. > When the number of SHOULD clauses is smaller than the minimum > number required, no results should be returned, except in the case > given below. > > > > > Regards, > > Paul Elschot > > > > > > On Tuesday 15 January 2008 13:04:51 Shai Erera wrote: > > > Hi > > > > > > I'm not sure if this is a bug or working as designed. In BooleanQuery, > one > > > can set the minimum number of SHOULD match terms. So if I send the > query > > > "abc +def" and set it to 1, only if "abc" has matches in the index I > should > > > get back results. > > > However, if I send the query "+def" and set the minimum to 1, I get > back > > > results, even though I don't have any SHOULD terms in the query. > However, if > > > I send the query "+abc +def" and set the minimum to 1, I get back 0 > results, > > > as expected. > > > I think this is actually a bug, mostly because the inconsistencies of > "+abc > > > +def" and "+def" with the minimum set to 1. > > > > > > The reason lies in BooleanQuery.rewrite, followed by Query.scorer. > > > BooleanQuery.rewrite has an optimization that if the number of clauses > is 1 > > > (as is in "+def"), the query returned is > clauses(0).getQuery().rewrite(), > > > which in this case is TermQuery. However, if the number of clauses is > > > greater than 1, the query returned is the BooleanQuery with all of its > > > clauses rewritten. > > That is indeed a bug in BooleanQuery.rewrite. > > Regards, > Paul Elschot > > > > > Then, the searcher calls query.scorer. > > > In the first case ("+def"), TermQuery.scorer is not aware of the > minimum > > > number should match constraint. > > > In the second ("+abc +def"), BooleanQuery.scorer returns a > BooleanScorer2, > > > which does handle the minimum number should match constraint. > > > > > > I think that a patch is pretty straight-forward, and I'll open an > issue and > > > provide the patch once you confirm this is indeed a bug. > > > > > > Cheers, > > > > > > Shai Erera > > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Regards, Shai Erera