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 Query.java
Date Tue, 14 Jan 2003 21:57:30 GMT
cutting     2003/01/14 13:57:30

  Modified:    src/java/org/apache/lucene/search BooleanQuery.java
                        PhrasePrefixQuery.java PhraseQuery.java Query.java
  Log:
  Fixed a bug where boosting was lost.
  
  Revision  Changes    Path
  1.10      +5 -2      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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BooleanQuery.java	14 Jan 2003 19:20:30 -0000	1.9
  +++ BooleanQuery.java	14 Jan 2003 21:57:30 -0000	1.10
  @@ -162,8 +162,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);
  +      if (!c.prohibited) {			  // just return clause weight
  +        Query clone = (Query)c.query.clone();
  +        clone.setBoost(getBoost() * clone.getBoost());
  +        return clone.createWeight(searcher);
  +      }
       }
       return new BooleanWeight(searcher);
     }
  
  
  
  1.6       +1 -0      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PhrasePrefixQuery.java	14 Jan 2003 19:20:30 -0000	1.5
  +++ PhrasePrefixQuery.java	14 Jan 2003 21:57:30 -0000	1.6
  @@ -210,6 +210,7 @@
         for (int i=0; i<terms.length; i++) {
           boq.add(new TermQuery(terms[i]), false, false);
         }
  +      boq.setBoost(getBoost());
         return boq.createWeight(searcher);
       }
       return new PhrasePrefixWeight(searcher);
  
  
  
  1.9       +3 -1      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PhraseQuery.java	14 Jan 2003 19:20:30 -0000	1.8
  +++ PhraseQuery.java	14 Jan 2003 21:57:30 -0000	1.9
  @@ -189,7 +189,9 @@
     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);
  +      Query termQuery = new TermQuery(term);
  +      termQuery.setBoost(getBoost());
  +      return termQuery.createWeight(searcher);
       }
       return new PhraseWeight(searcher);
     }
  
  
  
  1.10      +9 -1      jakarta-lucene/src/java/org/apache/lucene/search/Query.java
  
  Index: Query.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/Query.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Query.java	13 Jan 2003 23:50:33 -0000	1.9
  +++ Query.java	14 Jan 2003 21:57:30 -0000	1.10
  @@ -78,7 +78,7 @@
       <li>{@link org.apache.lucene.queryParser.QueryParser QueryParser}
       </ul>
   */
  -public abstract class Query implements java.io.Serializable {
  +public abstract class Query implements java.io.Serializable, Cloneable {
     private float boost = 1.0f;                     // query boost factor
   
     /** Sets the boost for this query clause to <code>b</code>.  Documents
  @@ -167,4 +167,12 @@
     }
   
   
  +  /** Returns a clone of this query. */
  +  public Object clone() {
  +    try {
  +      return (Query)super.clone();
  +    } catch (CloneNotSupportedException e) {
  +      throw new RuntimeException(e);
  +    }
  +  }
   }
  
  
  

--
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