diff --git a/CHANGES.txt b/CHANGES.txt index e969495496e..366b67374e3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -141,6 +141,10 @@ $Id$ fairly advanced programming, and I don't expect anyone to do this anytime soon, but at least now it is possible. + g. Added public accessors to the primitive query classes + (TermQuery, PhraseQuery and BooleanQuery), permitting access to + their terms and clauses. + Caution: These are extensive changes and they have not yet been tested extensively. Bug reports are appreciated. (cutting) diff --git a/src/java/org/apache/lucene/search/BooleanQuery.java b/src/java/org/apache/lucene/search/BooleanQuery.java index 7fd2061fa49..5d952f7dcac 100644 --- a/src/java/org/apache/lucene/search/BooleanQuery.java +++ b/src/java/org/apache/lucene/search/BooleanQuery.java @@ -135,13 +135,6 @@ public class BooleanQuery extends Query { } public Scorer scorer(IndexReader reader) throws IOException { - if (weights.size() == 1) { // optimize 1-clause queries - BooleanClause c = (BooleanClause)clauses.elementAt(0); - Weight w = (Weight)weights.elementAt(0); - if (!c.prohibited) // just return clause scorer - return w.scorer(reader); - } - BooleanScorer result = new BooleanScorer(searcher.getSimilarity()); for (int i = 0 ; i < weights.size(); i++) { @@ -167,6 +160,11 @@ public class BooleanQuery extends Query { } protected Weight createWeight(Searcher searcher) { + if (clauses.size() == 1) { // optimize 1-clause queries + BooleanClause c = (BooleanClause)clauses.elementAt(0); + if (!c.prohibited) // just return clause weight + return c.query.createWeight(searcher); + } return new BooleanWeight(searcher); } diff --git a/src/java/org/apache/lucene/search/PhrasePrefixQuery.java b/src/java/org/apache/lucene/search/PhrasePrefixQuery.java index d7658233345..073abace01b 100644 --- a/src/java/org/apache/lucene/search/PhrasePrefixQuery.java +++ b/src/java/org/apache/lucene/search/PhrasePrefixQuery.java @@ -155,20 +155,6 @@ public class PhrasePrefixQuery extends Query { if (termArrays.size() == 0) // optimize zero-term case return null; - if (termArrays.size() == 1) { // optimize one-term case - Term[] terms = (Term[])termArrays.get(0); - - BooleanScorer bos = new BooleanScorer(searcher.getSimilarity()); - for (int i=0; i