lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/search BooleanQuery.java PhrasePrefixQuery.java PhraseQuery.java
Date Tue, 14 Jan 2003 19:20:30 GMT
cutting     2003/01/14 11:20:30

  Modified:    .        CHANGES.txt
               src/java/org/apache/lucene/search BooleanQuery.java
                        PhrasePrefixQuery.java PhraseQuery.java
  Log:
  Fixed a bug with explain().
  
  Revision  Changes    Path
  1.42      +5 -1      jakarta-lucene/CHANGES.txt
  
  Index: CHANGES.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/CHANGES.txt,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- CHANGES.txt	14 Jan 2003 05:03:19 -0000	1.41
  +++ CHANGES.txt	14 Jan 2003 19:20:29 -0000	1.42
  @@ -141,6 +141,10 @@
          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)
  
  
  
  1.9       +5 -7      jakarta-lucene/src/java/org/apache/lucene/search/BooleanQuery.java
  
  Index: BooleanQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/BooleanQuery.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BooleanQuery.java	14 Jan 2003 00:04:37 -0000	1.8
  +++ BooleanQuery.java	14 Jan 2003 19:20:30 -0000	1.9
  @@ -135,13 +135,6 @@
       }
   
       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 @@
     }
   
     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);
     }
   
  
  
  
  1.5       +8 -14     jakarta-lucene/src/java/org/apache/lucene/search/PhrasePrefixQuery.java
  
  Index: PhrasePrefixQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/PhrasePrefixQuery.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PhrasePrefixQuery.java	13 Jan 2003 23:50:33 -0000	1.4
  +++ PhrasePrefixQuery.java	14 Jan 2003 19:20:30 -0000	1.5
  @@ -155,20 +155,6 @@
         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<terms.length; i++) {
  -          TermDocs docs = reader.termDocs(terms[i]);
  -          if (docs != null)
  -            bos.add(new TermScorer(this, docs, searcher.getSimilarity(),
  -                                   reader.norms(field)), false, false);
  -        }
  -      
  -        return bos;
  -      }
  -
         TermPositions[] tps = new TermPositions[termArrays.size()];
         for (int i=0; i<tps.length; i++) {
           Term[] terms = (Term[])termArrays.get(i);
  @@ -218,6 +204,14 @@
     }
   
     protected Weight createWeight(Searcher searcher) {
  +    if (termArrays.size() == 1) {                 // optimize one-term case
  +      Term[] terms = (Term[])termArrays.get(0);
  +      BooleanQuery boq = new BooleanQuery();
  +      for (int i=0; i<terms.length; i++) {
  +        boq.add(new TermQuery(terms[i]), false, false);
  +      }
  +      return boq.createWeight(searcher);
  +    }
       return new PhrasePrefixWeight(searcher);
     }
   
  
  
  
  1.8       +4 -8      jakarta-lucene/src/java/org/apache/lucene/search/PhraseQuery.java
  
  Index: PhraseQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/PhraseQuery.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PhraseQuery.java	13 Jan 2003 23:50:33 -0000	1.7
  +++ PhraseQuery.java	14 Jan 2003 19:20:30 -0000	1.8
  @@ -135,14 +135,6 @@
       public Scorer scorer(IndexReader reader) throws IOException {
         if (terms.size() == 0)			  // optimize zero-term case
           return null;
  -      if (terms.size() == 1) {			  // optimize one-term case
  -        Term term = (Term)terms.elementAt(0);
  -        TermDocs docs = reader.termDocs(term);
  -        if (docs == null)
  -          return null;
  -        return new TermScorer(this, docs, searcher.getSimilarity(),
  -                              reader.norms(term.field()));
  -      }
   
         TermPositions[] tps = new TermPositions[terms.size()];
         for (int i = 0; i < terms.size(); i++) {
  @@ -195,6 +187,10 @@
     }
   
     protected Weight createWeight(Searcher searcher) {
  +    if (terms.size() == 1) {			  // optimize one-term case
  +      Term term = (Term)terms.elementAt(0);
  +      return new TermQuery(term).createWeight(searcher);
  +    }
       return new PhraseWeight(searcher);
     }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message