lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r329381 - in /lucene/java/trunk/src/java/org/apache/lucene/search: ./ spans/
Date Sat, 29 Oct 2005 09:26:30 GMT
Author: ehatcher
Date: Sat Oct 29 02:26:21 2005
New Revision: 329381

URL: http://svn.apache.org/viewcvs?rev=329381&view=rev
Log:
Utilize ToStringUtils.boost() to remove duplication across .toString implementations and added
boost comparison in .equals methods where it was missing


Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/PhrasePrefixQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/PrefixQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java Sat Oct 29 02:26:21
2005
@@ -22,13 +22,14 @@
 import java.util.Vector;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.ToStringUtils;
 
 /** A Query that matches documents matching boolean combinations of other
   * queries, e.g. {@link TermQuery}s, {@link PhraseQuery}s or other
   * BooleanQuerys.
   */
 public class BooleanQuery extends Query {
-  
+
   /**
    * @deprecated use {@link #setMaxClauseCount(int)} instead
    */
@@ -314,15 +315,15 @@
 
   /** Indicates whether to use good old 1.4 BooleanScorer. */
   private static boolean useScorer14 = false;
-  
+
   public static void setUseScorer14(boolean use14) {
     useScorer14 = use14;
   }
-  
+
   public static boolean getUseScorer14() {
     return useScorer14;
   }
-  
+
   protected Weight createWeight(Searcher searcher) throws IOException {
     return getUseScorer14() ? (Weight) new BooleanWeight(searcher)
                             : (Weight) new BooleanWeight2(searcher);
@@ -386,25 +387,25 @@
     for (int i = 0 ; i < clauses.size(); i++) {
       BooleanClause c = (BooleanClause)clauses.elementAt(i);
       if (c.isProhibited())
-	buffer.append("-");
+        buffer.append("-");
       else if (c.isRequired())
-	buffer.append("+");
+        buffer.append("+");
 
       Query subQuery = c.getQuery();
       if (subQuery instanceof BooleanQuery) {	  // wrap sub-bools in parens
-	buffer.append("(");
-	buffer.append(c.getQuery().toString(field));
-	buffer.append(")");
+        buffer.append("(");
+        buffer.append(c.getQuery().toString(field));
+        buffer.append(")");
       } else
-	buffer.append(c.getQuery().toString(field));
+        buffer.append(c.getQuery().toString(field));
 
       if (i != clauses.size()-1)
-	buffer.append(" ");
+        buffer.append(" ");
     }
 
     if (getBoost() != 1.0) {
-      buffer.append(")^");
-      buffer.append(getBoost());
+      buffer.append(")");
+      buffer.append(ToStringUtils.boost(getBoost()));
     }
 
     return buffer.toString();

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java Sat Oct 29 02:26:21
2005
@@ -17,6 +17,8 @@
  */
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.ToStringUtils;
+
 import java.io.IOException;
 import java.util.BitSet;
 import java.util.Set;
@@ -125,7 +127,13 @@
 
   /** Prints a user-readable version of this query. */
   public String toString (String s) {
-    return "filtered("+query.toString(s)+")->"+filter;
+    StringBuffer buffer = new StringBuffer();
+    buffer.append("filtered(");
+    buffer.append(query.toString(s));
+    buffer.append(")->");
+    buffer.append(filter);
+    buffer.append(ToStringUtils.boost(getBoost()));
+    return buffer.toString();
   }
 
   /** Returns true iff <code>o</code> is equal to this. */

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java Sat Oct 29 02:26:21
2005
@@ -19,6 +19,7 @@
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.util.PriorityQueue;
+import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;
 
@@ -135,7 +136,17 @@
   }
     
   public String toString(String field) {
-    return super.toString(field) + '~' + Float.toString(minimumSimilarity);
+    StringBuffer buffer = new StringBuffer();
+    Term term = getTerm();
+    if (!term.field().equals(field)) {
+        buffer.append(term.field());
+        buffer.append(":");
+    }
+    buffer.append(term.text());
+    buffer.append('~');
+    buffer.append(Float.toString(minimumSimilarity));
+    buffer.append(ToStringUtils.boost(getBoost()));
+    return buffer.toString();
   }
   
   private static class ScoreTerm{

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java Sat Oct 29
02:26:21 2005
@@ -23,6 +23,7 @@
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.search.Weight;
+import org.apache.lucene.util.ToStringUtils;
 
 /**
  * A query that matches all documents.
@@ -130,10 +131,7 @@
   public String toString(String field) {
     StringBuffer buffer = new StringBuffer();
     buffer.append("MatchAllDocsQuery");
-    if (getBoost() != 1.0f) {
-      buffer.append("^");
-      buffer.append(Float.toString(getBoost()));
-    }
+    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java Sat Oct 29 02:26:21
2005
@@ -26,6 +26,7 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermPositions;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.util.ToStringUtils;
 
 /**
  * MultiPhraseQuery is a generalized version of PhraseQuery, with an added
@@ -72,7 +73,7 @@
 
     add(terms, position);
   }
-  
+
   /**
    * Allows to specify the relative position of terms within the phrase.
    * 
@@ -95,7 +96,7 @@
     termArrays.add(terms);
     positions.addElement(new Integer(position));
   }
-  
+
   /**
    * Returns the relative positions of terms in this phrase.
    */
@@ -144,23 +145,23 @@
     public Scorer scorer(IndexReader reader) throws IOException {
       if (termArrays.size() == 0)                  // optimize zero-term case
         return null;
-    
+
       TermPositions[] tps = new TermPositions[termArrays.size()];
       for (int i=0; i<tps.length; i++) {
         Term[] terms = (Term[])termArrays.get(i);
-      
+
         TermPositions p;
         if (terms.length > 1)
           p = new MultipleTermPositions(reader, terms);
         else
           p = reader.termPositions(terms[0]);
-      
+
         if (p == null)
           return null;
-      
+
         tps[i] = p;
       }
-    
+
       if (slop == 0)
         return new ExactPhraseScorer(this, tps, getPositions(), similarity,
                                      reader.norms(field));
@@ -168,14 +169,14 @@
         return new SloppyPhraseScorer(this, tps, getPositions(), similarity,
                                       slop, reader.norms(field));
     }
-    
+
     public Explanation explain(IndexReader reader, int doc)
       throws IOException {
       Explanation result = new Explanation();
       result.setDescription("weight("+getQuery()+" in "+doc+"), product of:");
 
       Explanation idfExpl = new Explanation(idf, "idf("+getQuery()+")");
-      
+
       // explain query weight
       Explanation queryExpl = new Explanation();
       queryExpl.setDescription("queryWeight(" + getQuery() + "), product of:");
@@ -185,16 +186,16 @@
         queryExpl.addDetail(boostExpl);
 
       queryExpl.addDetail(idfExpl);
-      
+
       Explanation queryNormExpl = new Explanation(queryNorm,"queryNorm");
       queryExpl.addDetail(queryNormExpl);
-      
+
       queryExpl.setValue(boostExpl.getValue() *
                          idfExpl.getValue() *
                          queryNormExpl.getValue());
 
       result.addDetail(queryExpl);
-     
+
       // explain field weight
       Explanation fieldExpl = new Explanation();
       fieldExpl.setDescription("fieldWeight("+getQuery()+" in "+doc+
@@ -215,7 +216,7 @@
       fieldExpl.setValue(tfExpl.getValue() *
                          idfExpl.getValue() *
                          fieldNormExpl.getValue());
-      
+
       result.addDetail(fieldExpl);
 
       // combine them
@@ -241,7 +242,7 @@
       return this;
     }
   }
-  
+
   protected Weight createWeight(Searcher searcher) throws IOException {
     return new MultiPhraseWeight(searcher);
   }
@@ -279,10 +280,7 @@
       buffer.append(slop);
     }
 
-    if (getBoost() != 1.0f) {
-      buffer.append("^");
-      buffer.append(Float.toString(getBoost()));
-    }
+    buffer.append(ToStringUtils.boost(getBoost()));
 
     return buffer.toString();
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java Sat Oct 29 02:26:21
2005
@@ -20,6 +20,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.util.ToStringUtils;
 
 /**
  * A {@link Query} that matches documents containing a subset of terms provided
@@ -75,10 +76,7 @@
             buffer.append(":");
         }
         buffer.append(term.text());
-        if (getBoost() != 1.0f) {
-            buffer.append("^");
-            buffer.append(Float.toString(getBoost()));
-        }
+        buffer.append(ToStringUtils.boost(getBoost()));
         return buffer.toString();
     }
 
@@ -90,7 +88,7 @@
 
       if (!term.equals(multiTermQuery.term)) return false;
 
-      return true;
+      return getBoost() == multiTermQuery.getBoost();
     }
 
     public int hashCode() {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/PhrasePrefixQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/PhrasePrefixQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/PhrasePrefixQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/PhrasePrefixQuery.java Sat Oct 29
02:26:21 2005
@@ -26,6 +26,7 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermPositions;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.util.ToStringUtils;
 
 /**
  * PhrasePrefixQuery is a generalized version of PhraseQuery, with an added
@@ -73,7 +74,7 @@
 
     add(terms, position);
   }
-  
+
   /**
    * Allows to specify the relative position of terms within the phrase.
    * 
@@ -96,7 +97,7 @@
     termArrays.add(terms);
     positions.addElement(new Integer(position));
   }
-  
+
   /**
    * Returns the relative positions of terms in this phrase.
    */
@@ -145,23 +146,23 @@
     public Scorer scorer(IndexReader reader) throws IOException {
       if (termArrays.size() == 0)                  // optimize zero-term case
         return null;
-    
+
       TermPositions[] tps = new TermPositions[termArrays.size()];
       for (int i=0; i<tps.length; i++) {
         Term[] terms = (Term[])termArrays.get(i);
-      
+
         TermPositions p;
         if (terms.length > 1)
           p = new MultipleTermPositions(reader, terms);
         else
           p = reader.termPositions(terms[0]);
-      
+
         if (p == null)
           return null;
-      
+
         tps[i] = p;
       }
-    
+
       if (slop == 0)
         return new ExactPhraseScorer(this, tps, getPositions(), similarity,
                                      reader.norms(field));
@@ -169,14 +170,14 @@
         return new SloppyPhraseScorer(this, tps, getPositions(), similarity,
                                       slop, reader.norms(field));
     }
-    
+
     public Explanation explain(IndexReader reader, int doc)
       throws IOException {
       Explanation result = new Explanation();
       result.setDescription("weight("+getQuery()+" in "+doc+"), product of:");
 
       Explanation idfExpl = new Explanation(idf, "idf("+getQuery()+")");
-      
+
       // explain query weight
       Explanation queryExpl = new Explanation();
       queryExpl.setDescription("queryWeight(" + getQuery() + "), product of:");
@@ -186,16 +187,16 @@
         queryExpl.addDetail(boostExpl);
 
       queryExpl.addDetail(idfExpl);
-      
+
       Explanation queryNormExpl = new Explanation(queryNorm,"queryNorm");
       queryExpl.addDetail(queryNormExpl);
-      
+
       queryExpl.setValue(boostExpl.getValue() *
                          idfExpl.getValue() *
                          queryNormExpl.getValue());
 
       result.addDetail(queryExpl);
-     
+
       // explain field weight
       Explanation fieldExpl = new Explanation();
       fieldExpl.setDescription("fieldWeight("+getQuery()+" in "+doc+
@@ -216,7 +217,7 @@
       fieldExpl.setValue(tfExpl.getValue() *
                          idfExpl.getValue() *
                          fieldNormExpl.getValue());
-      
+
       result.addDetail(fieldExpl);
 
       // combine them
@@ -265,10 +266,7 @@
       buffer.append(slop);
     }
 
-    if (getBoost() != 1.0f) {
-      buffer.append("^");
-      buffer.append(Float.toString(getBoost()));
-    }
+    buffer.append(ToStringUtils.boost(getBoost()));
 
     return buffer.toString();
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java Sat Oct 29 02:26:21
2005
@@ -23,6 +23,7 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermPositions;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.ToStringUtils;
 
 /** A Query that matches documents containing a particular sequence of terms.
  * A PhraseQuery is built by QueryParser for input like <code>"new york"</code>.
@@ -64,10 +65,10 @@
     int position = 0;
     if(positions.size() > 0)
         position = ((Integer) positions.lastElement()).intValue() + 1;
-    
+
     add(term, position);
   }
-  
+
   /**
    * Adds a term to the end of the query phrase.
    * The relative position of the term within the phrase is specified explicitly.
@@ -82,7 +83,7 @@
           field = term.field();
       else if (term.field() != field)
           throw new IllegalArgumentException("All phrase terms must be in the same field:
" + term);
-      
+
       terms.addElement(term);
       positions.addElement(new Integer(position));
   }
@@ -91,7 +92,7 @@
   public Term[] getTerms() {
     return (Term[])terms.toArray(new Term[0]);
   }
-  
+
   /**
    * Returns the relative positions of terms in this phrase.
    */
@@ -151,7 +152,7 @@
         return
           new SloppyPhraseScorer(this, tps, getPositions(), similarity, slop,
                                  reader.norms(field));
-      
+
     }
 
     public Explanation explain(IndexReader reader, int doc)
@@ -181,7 +182,7 @@
 
       Explanation idfExpl =
         new Explanation(idf, "idf(" + field + ": " + docFreqs + ")");
-      
+
       // explain query weight
       Explanation queryExpl = new Explanation();
       queryExpl.setDescription("queryWeight(" + getQuery() + "), product of:");
@@ -190,16 +191,16 @@
       if (getBoost() != 1.0f)
         queryExpl.addDetail(boostExpl);
       queryExpl.addDetail(idfExpl);
-      
+
       Explanation queryNormExpl = new Explanation(queryNorm,"queryNorm");
       queryExpl.addDetail(queryNormExpl);
-      
+
       queryExpl.setValue(boostExpl.getValue() *
                          idfExpl.getValue() *
                          queryNormExpl.getValue());
 
       result.addDetail(queryExpl);
-     
+
       // explain field weight
       Explanation fieldExpl = new Explanation();
       fieldExpl.setDescription("fieldWeight("+field+":"+query+" in "+doc+
@@ -220,7 +221,7 @@
       fieldExpl.setValue(tfExpl.getValue() *
                          idfExpl.getValue() *
                          fieldNormExpl.getValue());
-      
+
       result.addDetail(fieldExpl);
 
       // combine them
@@ -262,7 +263,7 @@
     for (int i = 0; i < terms.size(); i++) {
       buffer.append(((Term)terms.elementAt(i)).text());
       if (i != terms.size()-1)
-	buffer.append(" ");
+  buffer.append(" ");
     }
     buffer.append("\"");
 
@@ -271,10 +272,7 @@
       buffer.append(slop);
     }
 
-    if (getBoost() != 1.0f) {
-      buffer.append("^");
-      buffer.append(Float.toString(getBoost()));
-    }
+    buffer.append(ToStringUtils.boost(getBoost()));
 
     return buffer.toString();
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/PrefixQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/PrefixQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/PrefixQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/PrefixQuery.java Sat Oct 29 02:26:21
2005
@@ -21,6 +21,7 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.ToStringUtils;
 
 /** A Query that matches documents containing terms with a specified prefix. A PrefixQuery
  * is built by QueryParser for input like <code>app*</code>. */
@@ -69,10 +70,7 @@
     }
     buffer.append(prefix.text());
     buffer.append('*');
-    if (getBoost() != 1.0f) {
-      buffer.append("^");
-      buffer.append(Float.toString(getBoost()));
-    }
+    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java Sat Oct 29 02:26:21
2005
@@ -21,6 +21,7 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.ToStringUtils;
 
 /**
  * A Query that matches documents within an exclusive range. A RangeQuery
@@ -134,11 +135,7 @@
         buffer.append(" TO ");
         buffer.append(upperTerm != null ? upperTerm.text() : "null");
         buffer.append(inclusive ? "]" : "}");
-        if (getBoost() != 1.0f)
-        {
-            buffer.append("^");
-            buffer.append(Float.toString(getBoost()));
-        }
+        buffer.append(ToStringUtils.boost(getBoost()));
         return buffer.toString();
     }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java Sat Oct 29 02:26:21
2005
@@ -22,6 +22,7 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.ToStringUtils;
 
 /** A Query that matches documents containing a term.
   This may be combined with other terms with a {@link BooleanQuery}.
@@ -153,10 +154,7 @@
       buffer.append(":");
     }
     buffer.append(term.text());
-    if (getBoost() != 1.0f) {
-      buffer.append("^");
-      buffer.append(Float.toString(getBoost()));
-    }
+    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java Sat Oct
29 02:26:21 2005
@@ -22,6 +22,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.util.ToStringUtils;
 
 /** Matches spans near the beginning of a field. */
 public class SpanFirstQuery extends SpanQuery {
@@ -52,6 +53,7 @@
     buffer.append(", ");
     buffer.append(end);
     buffer.append(")");
+    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java Sat Oct 29
02:26:21 2005
@@ -26,6 +26,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.util.ToStringUtils;
 
 /** Matches spans which are near one another.  One can specify <i>slop</i>, the
  * maximum number of intervening unmatched positions, as well as whether
@@ -98,6 +99,7 @@
     buffer.append(", ");
     buffer.append(inOrder);
     buffer.append(")");
+    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 
@@ -141,7 +143,7 @@
     if (!clauses.equals(spanNearQuery.clauses)) return false;
     if (!field.equals(spanNearQuery.field)) return false;
 
-    return true;
+    return getBoost() == spanNearQuery.getBoost();
   }
 
   public int hashCode() {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNotQuery.java Sat Oct 29
02:26:21 2005
@@ -22,6 +22,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.util.ToStringUtils;
 
 /** Removes matches which overlap with another SpanQuery. */
 public class SpanNotQuery extends SpanQuery {
@@ -55,6 +56,7 @@
     buffer.append(", ");
     buffer.append(exclude.toString(field));
     buffer.append(")");
+    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanOrQuery.java Sat Oct 29
02:26:21 2005
@@ -25,6 +25,7 @@
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.util.PriorityQueue;
+import org.apache.lucene.util.ToStringUtils;
 import org.apache.lucene.search.Query;
 
 /** Matches the union of its clauses.*/
@@ -95,6 +96,7 @@
       }
     }
     buffer.append("])");
+    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 
@@ -107,7 +109,7 @@
     if (!clauses.equals(that.clauses)) return false;
     if (!field.equals(that.field)) return false;
 
-    return true;
+    return getBoost() == that.getBoost();
   }
 
   public int hashCode() {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java?rev=329381&r1=329380&r2=329381&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java Sat Oct 29
02:26:21 2005
@@ -24,6 +24,7 @@
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermPositions;
+import org.apache.lucene.util.ToStringUtils;
 
 /** Matches spans containing a term. */
 public class SpanTermQuery extends SpanQuery {
@@ -44,10 +45,13 @@
   }
 
   public String toString(String field) {
+    StringBuffer buffer = new StringBuffer();
     if (term.field().equals(field))
-      return term.text();
+      buffer.append(term.text());
     else
-      return term.toString();
+      buffer.append(term.toString());
+    buffer.append(ToStringUtils.boost(getBoost()));
+    return buffer.toString();
   }
 
   /** Returns true iff <code>o</code> is equal to this. */



Mime
View raw message