mirror of https://github.com/apache/lucene.git
LUCENE-1134: Fixed BooleanQuery.rewrite to only optimze a single clause query if minNumShouldMatch<=0.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@617963 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
18b61286fa
commit
3e6a40e89e
|
@ -22,6 +22,9 @@ API Changes
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
|
|
||||||
|
1. LUCENE-1134: Fixed BooleanQuery.rewrite to only optimze a single
|
||||||
|
clause query if minNumShouldMatch<=0. (Shai Erera via Michael Busch)
|
||||||
|
|
||||||
New features
|
New features
|
||||||
|
|
||||||
1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about a Token through the analysis
|
1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about a Token through the analysis
|
||||||
|
|
|
@ -363,7 +363,7 @@ public class BooleanQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Query rewrite(IndexReader reader) throws IOException {
|
public Query rewrite(IndexReader reader) throws IOException {
|
||||||
if (clauses.size() == 1) { // optimize 1-clause queries
|
if (minNrShouldMatch == 0 && clauses.size() == 1) { // optimize 1-clause queries
|
||||||
BooleanClause c = (BooleanClause)clauses.get(0);
|
BooleanClause c = (BooleanClause)clauses.get(0);
|
||||||
if (!c.isProhibited()) { // just return clause
|
if (!c.isProhibited()) { // just return clause
|
||||||
|
|
||||||
|
|
|
@ -284,6 +284,16 @@ public class TestBooleanMinShouldMatch extends LuceneTestCase {
|
||||||
verifyNrHits(q, 0);
|
verifyNrHits(q, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNoOptionalButMin2() throws Exception {
|
||||||
|
|
||||||
|
/* one required, no optional */
|
||||||
|
BooleanQuery q = new BooleanQuery();
|
||||||
|
q.add(new TermQuery(new Term("all", "all" )), BooleanClause.Occur.MUST);//true, false);
|
||||||
|
|
||||||
|
q.setMinimumNumberShouldMatch(1); // 1 of 0 optional
|
||||||
|
|
||||||
|
verifyNrHits(q, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void testRandomQueries() throws Exception {
|
public void testRandomQueries() throws Exception {
|
||||||
final Random rnd = new Random(0);
|
final Random rnd = new Random(0);
|
||||||
|
|
Loading…
Reference in New Issue