From a2042c190b22a71bc1845e6147ac1cfb5acdb62e Mon Sep 17 00:00:00 2001 From: Doug Cutting Date: Tue, 14 Jan 2003 19:20:30 +0000 Subject: [PATCH] Fixed a bug with explain(). git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149927 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 ++++ .../apache/lucene/search/BooleanQuery.java | 12 +++++----- .../lucene/search/PhrasePrefixQuery.java | 22 +++++++------------ .../org/apache/lucene/search/PhraseQuery.java | 12 ++++------ 4 files changed, 21 insertions(+), 29 deletions(-) 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