|
[
Permlink
| « Hide
]
Shai Erera added a comment - 15/Jan/08 07:10 PM
The fix is very trivial. Which tests should I run to ensure this doesn't break anything?
Shai Erera made changes - 15/Jan/08 07:10 PM
I'd start with these tests:
ant -Dtestcase='Test*Bool*' test-core You might also consider adding a test case in one of those tests that shows the bug without the patch applied. At first glance, the patch seems right .. but an optimization can probably be made ... if there is only once clause, and minNrShouldMatch is greater then 1, the query can rewrite itself to a "no-op" type query that doesn't match any docs.
Actually: BooleanQuery.rewrite can do something like that anytime minNrShouldMath is greater then the number of optional clauses. There is no real need for this optimization because BooleanScorer2 already uses a NonMatchingScorer for this case.
Ah... good call.
(Hmmm.... it stil might be worth doing just to make it clear to clients earlier rather then later that they won't match anything. ie:If you inspect a rewritten FuzzyQuery you get to see right away how many clauses it has ... why not let people inspecting a rewritten BooleanQuery in cases like this see right away that their query is a No-Op ?) A FuzzyQuery rewrites to a BooleanQuery with SHOULD clauses only, so a check and cast to BooleanQuery and then a clauses().size() == 0 can check for a No-Op after a rewrite().
I think you're misunderstanding me Paul: i was just trying to make an analogy – even if the Scorer optimizes away a BooleanQuery that can never match anything into a NonMatchingScorer, there are other advantages to having rewrite detect these situations (when it can) ... inspection of the rewritten queries being an example.
Hi
W.r.t. testing, I found TestBooleanMinShouldMatch. It had testNoOptionalButMin which added two MUST clauses. I added testNoOptionalButMin2 that adds only a single clause. It fails without the patch and passes with the patch. Other than that the tests in this class pass. W.r.t. the optimization that was discussed: I don't understand how it can be done. BooleanQuery has a clauses list. It is not aware of any SHOULD, MUST or MUST_NOT clauses in its rewrite() method. So how exactly this optimization can be done? The only class that seems to be aware of the type of clauses is BooleanScorer2 in its add() method.
Shai Erera made changes - 16/Jan/08 06:06 AM
Shai Erera made changes - 16/Jan/08 06:07 AM
Michael Busch made changes - 03/Feb/08 08:21 AM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||