You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2015/09/08 14:16:09 UTC

svn commit: r1701783 [2/6] - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/search/ lucene/core/src/java/org/apache/lucene/search/payloads/ lucene/core/src/java/org/apache/lucene/search/similarities/ l...

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TermRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TermRangeQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TermRangeQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TermRangeQuery.java Tue Sep  8 12:16:06 2015
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
 
 import org.apache.lucene.index.Term;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.ToStringUtils;
 import org.apache.lucene.util.automaton.Automata;
 import org.apache.lucene.util.automaton.Automaton;
 
@@ -121,7 +120,6 @@ public class TermRangeQuery extends Auto
     buffer.append(" TO ");
     buffer.append(upperTerm != null ? ("*".equals(Term.toString(upperTerm)) ? "\\*" : Term.toString(upperTerm)) : "*");
     buffer.append(includeUpper ? ']' : '}');
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TopTermsRewrite.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TopTermsRewrite.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TopTermsRewrite.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/TopTermsRewrite.java Tue Sep  8 12:16:06 2015
@@ -160,7 +160,7 @@ public abstract class TopTermsRewrite<B>
 
     for (final ScoreTerm st : scoreTerms) {
       final Term term = new Term(query.field, st.bytes.toBytesRef());
-      addClause(b, term, st.termState.docFreq(), query.getBoost() * st.boost, st.termState); // add to query
+      addClause(b, term, st.termState.docFreq(), st.boost, st.termState); // add to query
     }
     return build(b);
   }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java Tue Sep  8 12:16:06 2015
@@ -35,17 +35,6 @@ import org.apache.lucene.util.FrequencyT
  */
 public final class UsageTrackingQueryCachingPolicy implements QueryCachingPolicy {
 
-  private static Query cacheKey(Query query) {
-    if (query.getBoost() == 1f) {
-      return query;
-    } else {
-      Query key = query.clone();
-      key.setBoost(1f);
-      assert key == cacheKey(key);
-      return key;
-    }
-  }
-
   // the hash code that we use as a sentinel in the ring buffer.
   private static final int SENTINEL = Integer.MIN_VALUE;
 
@@ -109,9 +98,12 @@ public final class UsageTrackingQueryCac
 
   @Override
   public void onUse(Query query) {
-    // call possible Query clone and hashCode outside of sync block
+    assert query instanceof BoostQuery == false;
+    assert query instanceof ConstantScoreQuery == false;
+
+    // call hashCode outside of sync block
     // in case it's somewhat expensive:
-    int hashCode = cacheKey(query).hashCode();
+    int hashCode = query.hashCode();
 
     // we only track hash codes to avoid holding references to possible
     // large queries; this may cause rare false positives, but at worse
@@ -122,10 +114,12 @@ public final class UsageTrackingQueryCac
   }
 
   int frequency(Query query) {
-    
-    // call possible Query clone and hashCode outside of sync block
+    assert query instanceof BoostQuery == false;
+    assert query instanceof ConstantScoreQuery == false;
+
+    // call hashCode outside of sync block
     // in case it's somewhat expensive:
-    int hashCode = cacheKey(query).hashCode();
+    int hashCode = query.hashCode();
 
     synchronized (this) {
       return recentlyUsedFilters.frequency(hashCode);

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/Weight.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/Weight.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/Weight.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/Weight.java Tue Sep  8 12:16:06 2015
@@ -94,8 +94,8 @@ public abstract class Weight {
   /** The value for normalization of contained query clauses (e.g. sum of squared weights). */
   public abstract float getValueForNormalization() throws IOException;
 
-  /** Assigns the query normalization factor and boost from parent queries to this. */
-  public abstract void normalize(float norm, float topLevelBoost);
+  /** Assigns the query normalization factor and boost to this. */
+  public abstract void normalize(float norm, float boost);
 
   /**
    * Returns a {@link Scorer} which can iterate in order over all matching

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java Tue Sep  8 12:16:06 2015
@@ -21,7 +21,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.lucene.index.Term;
-import org.apache.lucene.util.ToStringUtils;
 import org.apache.lucene.util.automaton.Automata;
 import org.apache.lucene.util.automaton.Automaton;
 import org.apache.lucene.util.automaton.Operations;
@@ -121,7 +120,6 @@ public class WildcardQuery extends Autom
       buffer.append(":");
     }
     buffer.append(term.text());
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/package-info.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/package-info.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/package-info.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/package-info.java Tue Sep  8 12:16:06 2015
@@ -274,8 +274,8 @@
  *       <li><b>Index-time boost</b> by calling
  *        {@link org.apache.lucene.document.Field#setBoost(float) Field.setBoost()} before a document is 
  *        added to the index.</li>
- *       <li><b>Query-time boost</b> by setting a boost on a query clause, calling
- *        {@link org.apache.lucene.search.Query#setBoost(float) Query.setBoost()}.</li>
+ *       <li><b>Query-time boost</b> by applying a boost to a query by wrapping with
+ *       {@link org.apache.lucene.search.BoostQuery}.</li>
  *    </ul>    
  * <p>Indexing time boosts are pre-processed for storage efficiency and written to
  *    storage for a field as follows:
@@ -366,7 +366,7 @@
  *             <li>{@link org.apache.lucene.search.Query#rewrite(org.apache.lucene.index.IndexReader) rewrite(IndexReader reader)} &mdash; Rewrites queries into primitive queries. Primitive queries are:
  *                 {@link org.apache.lucene.search.TermQuery TermQuery},
  *                 {@link org.apache.lucene.search.BooleanQuery BooleanQuery}, <span
- *                     >and other queries that implement {@link org.apache.lucene.search.Query#createWeight(IndexSearcher,boolean) createWeight(IndexSearcher searcher,boolean)}</span></li>
+ *                     >and other queries that implement {@link org.apache.lucene.search.Query#createWeight(IndexSearcher,boolean) createWeight(IndexSearcher searcher,boolean,float)}</span></li>
  *         </ol>
  * <a name="weightClass"></a>
  * <h3>The Weight Interface</h3>
@@ -389,10 +389,10 @@
  *                 For example, with {@link org.apache.lucene.search.similarities.TFIDFSimilarity Lucene's classic vector-space formula}, this
  *                 is implemented as the sum of squared weights: <code>(idf * boost)<sup>2</sup></code></li>
  *             <li>
- *                 {@link org.apache.lucene.search.Weight#normalize(float,float) normalize(float norm, float topLevelBoost)} &mdash; 
+ *                 {@link org.apache.lucene.search.Weight#normalize(float,float) normalize(float norm, float boost)} &mdash; 
  *                 Performs query normalization: 
  *                 <ul>
- *                 <li><code>topLevelBoost</code>: A query-boost factor from any wrapping queries that should be multiplied into every
+ *                 <li><code>boost</code>: A query-boost factor from any wrapping queries that should be multiplied into every
  *                 document's score. For example, a TermQuery that is wrapped within a BooleanQuery with a boost of <code>5</code> would
  *                 receive this value at this time. This allows the TermQuery (the leaf node in this case) to compute this up-front
  *                 a single time (e.g. by multiplying into the IDF), rather than for every document.</li> 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java Tue Sep  8 12:16:06 2015
@@ -40,7 +40,6 @@ import org.apache.lucene.search.spans.Sp
 import org.apache.lucene.search.spans.SpanWeight;
 import org.apache.lucene.search.spans.Spans;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.ToStringUtils;
 
 /**
  * This class is very similar to
@@ -115,7 +114,6 @@ public class PayloadNearQuery extends Sp
     buffer.append(", ");
     buffer.append(inOrder);
     buffer.append(")");
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java Tue Sep  8 12:16:06 2015
@@ -101,11 +101,9 @@ public class PayloadSpanUtil {
       }
 
       SpanNearQuery sp = new SpanNearQuery(clauses, slop, inorder);
-      sp.setBoost(query.getBoost());
       getPayloads(payloads, sp);
     } else if (query instanceof TermQuery) {
       SpanTermQuery stq = new SpanTermQuery(((TermQuery) query).getTerm());
-      stq.setBoost(query.getBoost());
       getPayloads(payloads, stq);
     } else if (query instanceof SpanQuery) {
       getPayloads(payloads, (SpanQuery) query);
@@ -166,7 +164,6 @@ public class PayloadSpanUtil {
 
         SpanNearQuery sp = new SpanNearQuery(clauses, slop + positionGaps,
                                                       inorder);
-        sp.setBoost(query.getBoost());
         getPayloads(payloads, sp);
       }
     }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/SpanNearPayloadCheckQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/SpanNearPayloadCheckQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/SpanNearPayloadCheckQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/SpanNearPayloadCheckQuery.java Tue Sep  8 12:16:06 2015
@@ -50,7 +50,6 @@ public class SpanNearPayloadCheckQuery e
       buffer.append(';');
     }
     buffer.append(")");
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/SpanPayloadCheckQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/SpanPayloadCheckQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/SpanPayloadCheckQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/payloads/SpanPayloadCheckQuery.java Tue Sep  8 12:16:06 2015
@@ -153,18 +153,10 @@ public class SpanPayloadCheckQuery exten
       buffer.append(';');
     }
     buffer.append(")");
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 
   @Override
-  public SpanPayloadCheckQuery clone() {
-    SpanPayloadCheckQuery result = new SpanPayloadCheckQuery((SpanQuery) match.clone(), payloadToMatch);
-    result.setBoost(getBoost());
-    return result;
-  }
-
-  @Override
   public boolean equals(Object o) {
     if (! super.equals(o)) {
       return false;

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java Tue Sep  8 12:16:06 2015
@@ -198,7 +198,7 @@ public class BM25Similarity extends Simi
   }
 
   @Override
-  public final SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+  public final SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
     Explanation idf = termStats.length == 1 ? idfExplain(collectionStats, termStats[0]) : idfExplain(collectionStats, termStats);
 
     float avgdl = avgFieldLength(collectionStats);
@@ -208,7 +208,7 @@ public class BM25Similarity extends Simi
     for (int i = 0; i < cache.length; i++) {
       cache[i] = k1 * ((1 - b) + b * decodeNormValue((byte)i) / avgdl);
     }
-    return new BM25Stats(collectionStats.field(), idf, queryBoost, avgdl, cache);
+    return new BM25Stats(collectionStats.field(), idf, avgdl, cache);
   }
 
   @Override
@@ -259,10 +259,8 @@ public class BM25Similarity extends Simi
     private final Explanation idf;
     /** The average document length. */
     private final float avgdl;
-    /** query's inner boost */
-    private final float queryBoost;
-    /** query's outer boost (only for explain) */
-    private float topLevelBoost;
+    /** query boost */
+    private float boost;
     /** weight (idf * boost) */
     private float weight;
     /** field name, for pulling norms */
@@ -270,26 +268,25 @@ public class BM25Similarity extends Simi
     /** precomputed norm[256] with k1 * ((1 - b) + b * dl / avgdl) */
     private final float cache[];
 
-    BM25Stats(String field, Explanation idf, float queryBoost, float avgdl, float cache[]) {
+    BM25Stats(String field, Explanation idf, float avgdl, float cache[]) {
       this.field = field;
       this.idf = idf;
-      this.queryBoost = queryBoost;
       this.avgdl = avgdl;
       this.cache = cache;
+      normalize(1f, 1f);
     }
 
     @Override
     public float getValueForNormalization() {
       // we return a TF-IDF like normalization to be nice, but we don't actually normalize ourselves.
-      final float queryWeight = idf.getValue() * queryBoost;
-      return queryWeight * queryWeight;
+      return weight * weight;
     }
 
     @Override
-    public void normalize(float queryNorm, float topLevelBoost) {
+    public void normalize(float queryNorm, float boost) {
       // we don't normalize with queryNorm at all, we just capture the top-level boost
-      this.topLevelBoost = topLevelBoost;
-      this.weight = idf.getValue() * queryBoost * topLevelBoost;
+      this.boost = boost;
+      this.weight = idf.getValue() * boost;
     } 
   }
 
@@ -314,7 +311,7 @@ public class BM25Similarity extends Simi
   }
 
   private Explanation explainScore(int doc, Explanation freq, BM25Stats stats, NumericDocValues norms) {
-    Explanation boostExpl = Explanation.match(stats.queryBoost * stats.topLevelBoost, "boost");
+    Explanation boostExpl = Explanation.match(stats.boost, "boost");
     List<Explanation> subs = new ArrayList<>();
     if (boostExpl.getValue() != 1.0f)
       subs.add(boostExpl);

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/BasicStats.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/BasicStats.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/BasicStats.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/BasicStats.java Tue Sep  8 12:16:06 2015
@@ -37,21 +37,16 @@ public class BasicStats extends Similari
   protected long totalTermFreq;
   
   // -------------------------- Boost-related stuff --------------------------
-  
-  /** Query's inner boost. */
-  protected final float queryBoost;
-  /** Any outer query's boost. */
-  protected float topLevelBoost;
+
   /** For most Similarities, the immediate and the top level query boosts are
    * not handled differently. Hence, this field is just the product of the
    * other two. */
-  protected float totalBoost;
+  protected float boost;
   
-  /** Constructor. Sets the query boost. */
-  public BasicStats(String field, float queryBoost) {
+  /** Constructor. */
+  public BasicStats(String field) {
     this.field = field;
-    this.queryBoost = queryBoost;
-    this.totalBoost = queryBoost;
+    normalize(1f, 1f);
   }
   
   // ------------------------- Getter/setter methods -------------------------
@@ -128,19 +123,17 @@ public class BasicStats extends Similari
    * {@link #normalize(float, float)}, etc.
    */
   protected float rawNormalizationValue() {
-    return queryBoost;
+    return boost;
   }
   
-  /** No normalization is done. {@code topLevelBoost} is saved in the object,
-   * however. */
+  /** No normalization is done. {@code boost} is saved in the object, however. */
   @Override
-  public void normalize(float queryNorm, float topLevelBoost) {
-    this.topLevelBoost = topLevelBoost;
-    totalBoost = queryBoost * topLevelBoost;
+  public void normalize(float queryNorm, float boost) {
+    this.boost = boost;
   }
   
   /** Returns the total boost. */
-  public float getTotalBoost() {
-    return totalBoost;
+  public float getBoost() {
+    return boost;
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/DFRSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/DFRSimilarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/DFRSimilarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/DFRSimilarity.java Tue Sep  8 12:16:06 2015
@@ -109,15 +109,15 @@ public class DFRSimilarity extends Simil
   @Override
   protected float score(BasicStats stats, float freq, float docLen) {
     float tfn = normalization.tfn(stats, freq, docLen);
-    return stats.getTotalBoost() *
+    return stats.getBoost() *
         basicModel.score(stats, tfn) * afterEffect.score(stats, tfn);
   }
   
   @Override
   protected void explain(List<Explanation> subs,
       BasicStats stats, int doc, float freq, float docLen) {
-    if (stats.getTotalBoost() != 1.0f) {
-      subs.add(Explanation.match(stats.getTotalBoost(), "boost"));
+    if (stats.getBoost() != 1.0f) {
+      subs.add(Explanation.match(stats.getBoost(), "boost"));
     }
     
     Explanation normExpl = normalization.explain(stats, freq, docLen);

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/IBSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/IBSimilarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/IBSimilarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/IBSimilarity.java Tue Sep  8 12:16:06 2015
@@ -96,7 +96,7 @@ public class IBSimilarity extends Simila
   
   @Override
   protected float score(BasicStats stats, float freq, float docLen) {
-    return stats.getTotalBoost() *
+    return stats.getBoost() *
         distribution.score(
             stats,
             normalization.tfn(stats, freq, docLen),
@@ -106,8 +106,8 @@ public class IBSimilarity extends Simila
   @Override
   protected void explain(
       List<Explanation> subs, BasicStats stats, int doc, float freq, float docLen) {
-    if (stats.getTotalBoost() != 1.0f) {
-      subs.add(Explanation.match(stats.getTotalBoost(), "boost"));
+    if (stats.getBoost() != 1.0f) {
+      subs.add(Explanation.match(stats.getBoost(), "boost"));
     }
     Explanation normExpl = normalization.explain(stats, freq, docLen);
     Explanation lambdaExpl = lambda.explain(stats);

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMDirichletSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMDirichletSimilarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMDirichletSimilarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMDirichletSimilarity.java Tue Sep  8 12:16:06 2015
@@ -64,7 +64,7 @@ public class LMDirichletSimilarity exten
   
   @Override
   protected float score(BasicStats stats, float freq, float docLen) {
-    float score = stats.getTotalBoost() * (float)(Math.log(1 + freq /
+    float score = stats.getBoost() * (float)(Math.log(1 + freq /
         (mu * ((LMStats)stats).getCollectionProbability())) +
         Math.log(mu / (docLen + mu)));
     return score > 0.0f ? score : 0.0f;
@@ -73,8 +73,8 @@ public class LMDirichletSimilarity exten
   @Override
   protected void explain(List<Explanation> subs, BasicStats stats, int doc,
       float freq, float docLen) {
-    if (stats.getTotalBoost() != 1.0f) {
-      subs.add(Explanation.match(stats.getTotalBoost(), "boost"));
+    if (stats.getBoost() != 1.0f) {
+      subs.add(Explanation.match(stats.getBoost(), "boost"));
     }
 
     subs.add(Explanation.match(mu, "mu"));

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java Tue Sep  8 12:16:06 2015
@@ -52,7 +52,7 @@ public class LMJelinekMercerSimilarity e
   
   @Override
   protected float score(BasicStats stats, float freq, float docLen) {
-    return stats.getTotalBoost() *
+    return stats.getBoost() *
         (float)Math.log(1 +
             ((1 - lambda) * freq / docLen) /
             (lambda * ((LMStats)stats).getCollectionProbability()));
@@ -61,8 +61,8 @@ public class LMJelinekMercerSimilarity e
   @Override
   protected void explain(List<Explanation> subs, BasicStats stats, int doc,
       float freq, float docLen) {
-    if (stats.getTotalBoost() != 1.0f) {
-      subs.add(Explanation.match(stats.getTotalBoost(), "boost"));
+    if (stats.getBoost() != 1.0f) {
+      subs.add(Explanation.match(stats.getBoost(), "boost"));
     }
     subs.add(Explanation.match(lambda, "lambda"));
     super.explain(subs, stats, doc, freq, docLen);

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMSimilarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMSimilarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/LMSimilarity.java Tue Sep  8 12:16:06 2015
@@ -54,8 +54,8 @@ public abstract class LMSimilarity exten
   }
   
   @Override
-  protected BasicStats newStats(String field, float queryBoost) {
-    return new LMStats(field, queryBoost);
+  protected BasicStats newStats(String field) {
+    return new LMStats(field);
   }
 
   /**
@@ -108,8 +108,8 @@ public abstract class LMSimilarity exten
     /**
      * Creates LMStats for the provided field and query-time boost
      */
-    public LMStats(String field, float queryBoost) {
-      super(field, queryBoost);
+    public LMStats(String field) {
+      super(field);
     }
     
     /**

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java Tue Sep  8 12:16:06 2015
@@ -50,10 +50,10 @@ public class MultiSimilarity extends Sim
   }
 
   @Override
-  public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+  public SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
     SimWeight subStats[] = new SimWeight[sims.length];
     for (int i = 0; i < subStats.length; i++) {
-      subStats[i] = sims[i].computeWeight(queryBoost, collectionStats, termStats);
+      subStats[i] = sims[i].computeWeight(collectionStats, termStats);
     }
     return new MultiStats(subStats);
   }
@@ -120,9 +120,9 @@ public class MultiSimilarity extends Sim
     }
 
     @Override
-    public void normalize(float queryNorm, float topLevelBoost) {
+    public void normalize(float queryNorm, float boost) {
       for (SimWeight stat : subStats) {
-        stat.normalize(queryNorm, topLevelBoost);
+        stat.normalize(queryNorm, boost);
       }
     }
   }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/PerFieldSimilarityWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/PerFieldSimilarityWrapper.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/PerFieldSimilarityWrapper.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/PerFieldSimilarityWrapper.java Tue Sep  8 12:16:06 2015
@@ -46,10 +46,10 @@ public abstract class PerFieldSimilarity
   }
 
   @Override
-  public final SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+  public final SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
     PerFieldSimWeight weight = new PerFieldSimWeight();
     weight.delegate = get(collectionStats.field());
-    weight.delegateWeight = weight.delegate.computeWeight(queryBoost, collectionStats, termStats);
+    weight.delegateWeight = weight.delegate.computeWeight(collectionStats, termStats);
     return weight;
   }
 
@@ -74,8 +74,8 @@ public abstract class PerFieldSimilarity
     }
     
     @Override
-    public void normalize(float queryNorm, float topLevelBoost) {
-      delegateWeight.normalize(queryNorm, topLevelBoost);
+    public void normalize(float queryNorm, float boost) {
+      delegateWeight.normalize(queryNorm, boost);
     }
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java Tue Sep  8 12:16:06 2015
@@ -78,7 +78,7 @@ import java.util.Collections;
  * <a name="querytime">Query time</a>
  * At query-time, Queries interact with the Similarity via these steps:
  * <ol>
- *   <li>The {@link #computeWeight(float, CollectionStatistics, TermStatistics...)} method is called a single time,
+ *   <li>The {@link #computeWeight(CollectionStatistics, TermStatistics...)} method is called a single time,
  *       allowing the implementation to compute any statistics (such as IDF, average document length, etc)
  *       across <i>the entire collection</i>. The {@link TermStatistics} and {@link CollectionStatistics} passed in 
  *       already contain all of the raw statistics involved, so a Similarity can freely use any combination
@@ -158,16 +158,15 @@ public abstract class Similarity {
   /**
    * Compute any collection-level weight (e.g. IDF, average document length, etc) needed for scoring a query.
    *
-   * @param queryBoost the query-time boost.
    * @param collectionStats collection-level statistics, such as the number of tokens in the collection.
    * @param termStats term-level statistics, such as the document frequency of a term across the collection.
    * @return SimWeight object with the information this Similarity needs to score a query.
    */
-  public abstract SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats);
+  public abstract SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats);
 
   /**
    * Creates a new {@link Similarity.SimScorer} to score matching documents from a segment of the inverted index.
-   * @param weight collection information from {@link #computeWeight(float, CollectionStatistics, TermStatistics...)}
+   * @param weight collection information from {@link #computeWeight(CollectionStatistics, TermStatistics...)}
    * @param context segment of the inverted index to be scored.
    * @return SloppySimScorer for scoring documents across <code>context</code>
    * @throws IOException if there is a low-level I/O error
@@ -243,8 +242,11 @@ public abstract class Similarity {
      * <p>
      * NOTE: a Similarity implementation might not use this normalized value at all,
      * it's not required. However, it's usually a good idea to at least incorporate 
-     * the topLevelBoost (e.g. from an outer BooleanQuery) into its score.
+     * the boost into its score.
+     * <p>
+     * NOTE: If this method is called several times, it behaves as if only the
+     * last call was performed.
      */
-    public abstract void normalize(float queryNorm, float topLevelBoost);
+    public abstract void normalize(float queryNorm, float boost);
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java Tue Sep  8 12:16:06 2015
@@ -83,18 +83,18 @@ public abstract class SimilarityBase ext
   }
   
   @Override
-  public final SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+  public final SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
     BasicStats stats[] = new BasicStats[termStats.length];
     for (int i = 0; i < termStats.length; i++) {
-      stats[i] = newStats(collectionStats.field(), queryBoost);
+      stats[i] = newStats(collectionStats.field());
       fillBasicStats(stats[i], collectionStats, termStats[i]);
     }
     return stats.length == 1 ? stats[0] : new MultiSimilarity.MultiStats(stats);
   }
   
   /** Factory method to return a custom stats object */
-  protected BasicStats newStats(String field, float queryBoost) {
-    return new BasicStats(field, queryBoost);
+  protected BasicStats newStats(String field) {
+    return new BasicStats(field);
   }
   
   /** Fills all member fields defined in {@code BasicStats} in {@code stats}. 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java Tue Sep  8 12:16:06 2015
@@ -414,7 +414,7 @@ import org.apache.lucene.util.BytesRef;
  *        <tr>
  *          <td valign="middle" align="right" rowspan="1">
  *            {@link org.apache.lucene.search.Weight#getValueForNormalization() sumOfSquaredWeights} &nbsp; = &nbsp;
- *            {@link org.apache.lucene.search.Query#getBoost() q.getBoost()} <sup><big>2</big></sup>
+ *            {@link org.apache.lucene.search.BoostQuery#getBoost() q.getBoost()} <sup><big>2</big></sup>
  *            &nbsp;&middot;&nbsp;
  *          </td>
  *          <td valign="bottom" align="center" rowspan="1" style="text-align: center">
@@ -443,13 +443,13 @@ import org.apache.lucene.util.BytesRef;
  *      is a search time boost of term <i>t</i> in the query <i>q</i> as
  *      specified in the query text
  *      (see <A HREF="{@docRoot}/../queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Boosting_a_Term">query syntax</A>),
- *      or as set by application calls to
- *      {@link org.apache.lucene.search.Query#setBoost(float) setBoost()}.
+ *      or as set by wrapping with
+ *      {@link org.apache.lucene.search.BoostQuery#BoostQuery(org.apache.lucene.search.Query, float) BoostQuery}.
  *      Notice that there is really no direct API for accessing a boost of one term in a multi term query,
  *      but rather multi terms are represented in a query as multi
  *      {@link org.apache.lucene.search.TermQuery TermQuery} objects,
  *      and so the boost of a term in the query is accessible by calling the sub-query
- *      {@link org.apache.lucene.search.Query#getBoost() getBoost()}.
+ *      {@link org.apache.lucene.search.BoostQuery#getBoost() getBoost()}.
  *      <br>&nbsp;<br>
  *    </li>
  *
@@ -684,11 +684,11 @@ public abstract class TFIDFSimilarity ex
   public abstract float scorePayload(int doc, int start, int end, BytesRef payload);
 
   @Override
-  public final SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+  public final SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
     final Explanation idf = termStats.length == 1
     ? idfExplain(collectionStats, termStats[0])
     : idfExplain(collectionStats, termStats);
-    return new IDFStats(collectionStats.field(), idf, queryBoost);
+    return new IDFStats(collectionStats.field(), idf);
   }
 
   @Override
@@ -738,16 +738,15 @@ public abstract class TFIDFSimilarity ex
     /** The idf and its explanation */
     private final Explanation idf;
     private float queryNorm;
+    private float boost;
     private float queryWeight;
-    private final float queryBoost;
     private float value;
     
-    public IDFStats(String field, Explanation idf, float queryBoost) {
+    public IDFStats(String field, Explanation idf) {
       // TODO: Validate?
       this.field = field;
       this.idf = idf;
-      this.queryBoost = queryBoost;
-      this.queryWeight = idf.getValue() * queryBoost; // compute query weight
+      normalize(1f, 1f);
     }
 
     @Override
@@ -757,9 +756,10 @@ public abstract class TFIDFSimilarity ex
     }
 
     @Override
-    public void normalize(float queryNorm, float topLevelBoost) {
-      this.queryNorm = queryNorm * topLevelBoost;
-      queryWeight *= this.queryNorm;              // normalize query weight
+    public void normalize(float queryNorm, float boost) {
+      this.boost = boost;
+      this.queryNorm = queryNorm;
+      queryWeight = queryNorm * boost * idf.getValue();
       value = queryWeight * idf.getValue();         // idf for document
     }
   }  
@@ -767,8 +767,8 @@ public abstract class TFIDFSimilarity ex
   private Explanation explainQuery(IDFStats stats) {
     List<Explanation> subs = new ArrayList<>();
 
-    Explanation boostExpl = Explanation.match(stats.queryBoost, "boost");
-    if (stats.queryBoost != 1.0f)
+    Explanation boostExpl = Explanation.match(stats.boost, "boost");
+    if (stats.boost != 1.0f)
       subs.add(boostExpl);
     subs.add(stats.idf);
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java Tue Sep  8 12:16:06 2015
@@ -23,7 +23,6 @@ import java.util.Objects;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.util.ToStringUtils;
 
 /**
  * <p>Wrapper to allow {@link SpanQuery} objects participate in composite 
@@ -68,9 +67,9 @@ import org.apache.lucene.util.ToStringUt
  * but with the term statistics of the real field. This may lead to exceptions,
  * poor performance, and unexpected scoring behaviour.
  */
-public class FieldMaskingSpanQuery extends SpanQuery {
-  private SpanQuery maskedQuery;
-  private String field;
+public final class FieldMaskingSpanQuery extends SpanQuery {
+  private final SpanQuery maskedQuery;
+  private final String field;
     
   public FieldMaskingSpanQuery(SpanQuery maskedQuery, String maskedField) {
     this.maskedQuery = Objects.requireNonNull(maskedQuery);
@@ -96,19 +95,17 @@ public class FieldMaskingSpanQuery exten
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     FieldMaskingSpanQuery clone = null;
 
     SpanQuery rewritten = (SpanQuery) maskedQuery.rewrite(reader);
     if (rewritten != maskedQuery) {
-      clone = (FieldMaskingSpanQuery) this.clone();
-      clone.maskedQuery = rewritten;
+      return new FieldMaskingSpanQuery(rewritten, field);
     }
 
-    if (clone != null) {
-      return clone;
-    } else {
-      return this;
-    }
+    return super.rewrite(reader);
   }
 
   @Override
@@ -117,7 +114,6 @@ public class FieldMaskingSpanQuery exten
     buffer.append("mask(");
     buffer.append(maskedQuery.toString(field));
     buffer.append(")");
-    buffer.append(ToStringUtils.boost(getBoost()));
     buffer.append(" as ");
     buffer.append(this.field);
     return buffer.toString();

Copied: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanBoostQuery.java (from r1701621, lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/spans/SpanBoostQuery.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanBoostQuery.java?p2=lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanBoostQuery.java&p1=lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/spans/SpanBoostQuery.java&r1=1701621&r2=1701783&rev=1701783&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/spans/SpanBoostQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanBoostQuery.java Tue Sep  8 12:16:06 2015
@@ -100,6 +100,10 @@ public final class SpanBoostQuery extend
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
+    if (super.getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
+
     if (boost == 1f) {
       return query;
     }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainQuery.java Tue Sep  8 12:16:06 2015
@@ -35,7 +35,7 @@ abstract class SpanContainQuery extends
   SpanQuery big;
   SpanQuery little;
 
-  SpanContainQuery(SpanQuery big, SpanQuery little, float boost) {
+  SpanContainQuery(SpanQuery big, SpanQuery little) {
     this.big = Objects.requireNonNull(big);
     this.little = Objects.requireNonNull(little);
     Objects.requireNonNull(big.getField());
@@ -43,7 +43,6 @@ abstract class SpanContainQuery extends
     if (! big.getField().equals(little.getField())) {
       throw new IllegalArgumentException("big and little not same field");
     }
-    this.setBoost(boost);
   }
 
   @Override
@@ -105,22 +104,19 @@ abstract class SpanContainQuery extends
   }
 
   @Override
-  public abstract SpanContainQuery clone();
-
-  @Override
   public Query rewrite(IndexReader reader) throws IOException {
-    SpanContainQuery clone = null;
-    SpanQuery rewrittenBig = (SpanQuery) big.rewrite(reader);
-    if (rewrittenBig != big) {
-      clone = this.clone();
-      clone.big = rewrittenBig;
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
     }
+    SpanQuery rewrittenBig = (SpanQuery) big.rewrite(reader);
     SpanQuery rewrittenLittle = (SpanQuery) little.rewrite(reader);
-    if (rewrittenLittle != little) {
-      if (clone == null) clone = this.clone();
+    if (big != rewrittenBig || little != rewrittenLittle) {
+      SpanContainQuery clone = (SpanContainQuery) super.clone();
+      clone.big = rewrittenBig;
       clone.little = rewrittenLittle;
+      return clone;
     }
-    return (clone != null) ? clone : this;
+    return super.rewrite(reader);
   }
 
   @Override

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java Tue Sep  8 12:16:06 2015
@@ -25,17 +25,16 @@ import org.apache.lucene.index.LeafReade
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.util.Bits;
 
 /** Keep matches that contain another Spans. */
-public class SpanContainingQuery extends SpanContainQuery {
+public final class SpanContainingQuery extends SpanContainQuery {
   /** Construct a SpanContainingQuery matching spans from <code>big</code>
    * that contain at least one spans from <code>little</code>.
    * This query has the boost of <code>big</code>.
    * <code>big</code> and <code>little</code> must be in the same field.
    */
   public SpanContainingQuery(SpanQuery big, SpanQuery little) {
-    super(big, little, big.getBoost());
+    super(big, little);
   }
 
   @Override
@@ -44,13 +43,6 @@ public class SpanContainingQuery extends
   }
 
   @Override
-  public SpanContainingQuery clone() {
-    return new SpanContainingQuery(
-          (SpanQuery) big.clone(),
-          (SpanQuery) little.clone());
-  }
-
-  @Override
   public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
     SpanWeight bigWeight = big.createWeight(searcher, false);
     SpanWeight littleWeight = little.createWeight(searcher, false);

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java Tue Sep  8 12:16:06 2015
@@ -18,7 +18,6 @@ package org.apache.lucene.search.spans;
  */
 
 import org.apache.lucene.search.spans.FilterSpans.AcceptStatus;
-import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;
 
@@ -54,15 +53,7 @@ public class SpanFirstQuery extends Span
     buffer.append(", ");
     buffer.append(end);
     buffer.append(")");
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 
-  @Override
-  public SpanFirstQuery clone() {
-    SpanFirstQuery spanFirstQuery = new SpanFirstQuery((SpanQuery) match.clone(), end);
-    spanFirstQuery.setBoost(getBoost());
-    return spanFirstQuery;
-  }
-
 }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java Tue Sep  8 12:16:06 2015
@@ -111,19 +111,17 @@ public class SpanMultiTermQueryWrapper<Q
     builder.append("SpanMultiTermQueryWrapper(");
     builder.append(query.toString(field));
     builder.append(")");
-    if (getBoost() != 1F) {
-      builder.append('^');
-      builder.append(getBoost());
-    }
     return builder.toString();
   }
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     final Query q = query.rewrite(reader);
     if (!(q instanceof SpanQuery))
       throw new UnsupportedOperationException("You can only use SpanMultiTermQueryWrapper with a suitable SpanRewriteMethod.");
-    q.setBoost(q.getBoost() * getBoost()); // multiply boost
     return q;
   }
   
@@ -177,7 +175,6 @@ public class SpanMultiTermQueryWrapper<Q
       @Override
       protected void addClause(SpanOrQuery topLevel, Term term, int docCount, float boost, TermContext states) {
         final SpanTermQuery q = new SpanTermQuery(term, states);
-        q.setBoost(boost);
         topLevel.addClause(q);
       }
     };
@@ -226,7 +223,6 @@ public class SpanMultiTermQueryWrapper<Q
         @Override
         protected void addClause(SpanOrQuery topLevel, Term term, int docFreq, float boost, TermContext states) {
           final SpanTermQuery q = new SpanTermQuery(term, states);
-          q.setBoost(boost);
           topLevel.addClause(q);
         }
       };

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java Tue Sep  8 12:16:06 2015
@@ -181,7 +181,6 @@ public class SpanNearQuery extends SpanQ
     buffer.append(", ");
     buffer.append(inOrder);
     buffer.append(")");
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 
@@ -243,34 +242,23 @@ public class SpanNearQuery extends SpanQ
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
-    SpanNearQuery clone = null;
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
+    boolean actuallyRewritten = false;
+    List<SpanQuery> rewrittenClauses = new ArrayList<>();
     for (int i = 0 ; i < clauses.size(); i++) {
       SpanQuery c = clauses.get(i);
       SpanQuery query = (SpanQuery) c.rewrite(reader);
-      if (query != c) {                     // clause rewrote: must clone
-        if (clone == null)
-          clone = this.clone();
-        clone.clauses.set(i,query);
-      }
+      actuallyRewritten |= query != c;
+      rewrittenClauses.add(query);
     }
-    if (clone != null) {
-      return clone; // some clauses rewrote
-    } else {
-      return this; // no clauses rewrote
+    if (actuallyRewritten) {
+      SpanNearQuery rewritten = (SpanNearQuery) clone();
+      rewritten.clauses = rewrittenClauses;
+      return rewritten;
     }
-  }
-
-  @Override
-  public SpanNearQuery clone() {
-    int sz = clauses.size();
-    SpanQuery[] newClauses = new SpanQuery[sz];
-
-    for (int i = 0; i < sz; i++) {
-      newClauses[i] = (SpanQuery) clauses.get(i).clone();
-    }
-    SpanNearQuery spanNearQuery = new SpanNearQuery(newClauses, slop, inOrder);
-    spanNearQuery.setBoost(getBoost());
-    return spanNearQuery;
+    return super.rewrite(reader);
   }
 
   /** Returns true iff <code>o</code> is equal to this. */

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java Tue Sep  8 12:16:06 2015
@@ -35,7 +35,7 @@ import org.apache.lucene.util.ToStringUt
 /** Removes matches which overlap with another SpanQuery or which are
  * within x tokens before or y tokens after another SpanQuery.
  */
-public class SpanNotQuery extends SpanQuery implements Cloneable {
+public final class SpanNotQuery extends SpanQuery {
   private SpanQuery include;
   private SpanQuery exclude;
   private final int pre;
@@ -89,17 +89,9 @@ public class SpanNotQuery extends SpanQu
     buffer.append(", ");
     buffer.append(Integer.toString(post));
     buffer.append(")");
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 
-  @Override
-  public SpanNotQuery clone() {
-    SpanNotQuery spanNotQuery = new SpanNotQuery((SpanQuery) include.clone(),
-                                                                (SpanQuery) exclude.clone(), pre, post);
-    spanNotQuery.setBoost(getBoost());
-    return spanNotQuery;
-  }
 
   @Override
   public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
@@ -201,24 +193,15 @@ public class SpanNotQuery extends SpanQu
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
-    SpanNotQuery clone = null;
-
-    SpanQuery rewrittenInclude = (SpanQuery) include.rewrite(reader);
-    if (rewrittenInclude != include) {
-      clone = this.clone();
-      clone.include = rewrittenInclude;
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
     }
+    SpanQuery rewrittenInclude = (SpanQuery) include.rewrite(reader);
     SpanQuery rewrittenExclude = (SpanQuery) exclude.rewrite(reader);
-    if (rewrittenExclude != exclude) {
-      if (clone == null) clone = this.clone();
-      clone.exclude = rewrittenExclude;
-    }
-
-    if (clone != null) {
-      return clone;                        // some clauses rewrote
-    } else {
-      return this;                         // no clauses rewrote
+    if (rewrittenInclude != include || rewrittenExclude != exclude) {
+      return new SpanNotQuery(rewrittenInclude, rewrittenExclude);
     }
+    return super.rewrite(reader);
   }
 
     /** Returns true iff <code>o</code> is equal to this. */

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java Tue Sep  8 12:16:06 2015
@@ -34,12 +34,11 @@ import org.apache.lucene.search.Disjunct
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.util.ToStringUtils;
 
 
 /** Matches the union of its clauses.
  */
-public class SpanOrQuery extends SpanQuery implements Cloneable {
+public final class SpanOrQuery extends SpanQuery {
   private List<SpanQuery> clauses;
   private String field;
 
@@ -72,35 +71,22 @@ public class SpanOrQuery extends SpanQue
   public String getField() { return field; }
 
   @Override
-  public SpanOrQuery clone() {
-    int sz = clauses.size();
-    SpanQuery[] newClauses = new SpanQuery[sz];
-
-    for (int i = 0; i < sz; i++) {
-      newClauses[i] = (SpanQuery) clauses.get(i).clone();
-    }
-    SpanOrQuery soq = new SpanOrQuery(newClauses);
-    soq.setBoost(getBoost());
-    return soq;
-  }
-
-  @Override
   public Query rewrite(IndexReader reader) throws IOException {
-    SpanOrQuery clone = null;
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
+    SpanOrQuery rewritten = new SpanOrQuery();
+    boolean actuallyRewritten = false;
     for (int i = 0 ; i < clauses.size(); i++) {
       SpanQuery c = clauses.get(i);
       SpanQuery query = (SpanQuery) c.rewrite(reader);
-      if (query != c) {                     // clause rewrote: must clone
-        if (clone == null)
-          clone = this.clone();
-        clone.clauses.set(i,query);
-      }
+      actuallyRewritten |= query != c;
+      rewritten.addClause(query);
     }
-    if (clone != null) {
-      return clone;                        // some clauses rewrote
-    } else {
-      return this;                         // no clauses rewrote
+    if (actuallyRewritten) {
+      return rewritten;
     }
+    return super.rewrite(reader);
   }
 
   @Override
@@ -116,7 +102,6 @@ public class SpanOrQuery extends SpanQue
       }
     }
     buffer.append("])");
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionCheckQuery.java Tue Sep  8 12:16:06 2015
@@ -107,19 +107,17 @@ public abstract class SpanPositionCheckQ
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
-    SpanPositionCheckQuery clone = null;
-
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     SpanQuery rewritten = (SpanQuery) match.rewrite(reader);
     if (rewritten != match) {
-      clone = (SpanPositionCheckQuery) this.clone();
+      SpanPositionCheckQuery clone = (SpanPositionCheckQuery) this.clone();
       clone.match = rewritten;
+      return clone;
     }
 
-    if (clone != null) {
-      return clone;                        // some clauses rewrote
-    } else {
-      return this;                         // no clauses rewrote
-    }
+    return super.rewrite(reader);
   }
 
   /** Returns true iff <code>o</code> is equal to this. */

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionRangeQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionRangeQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanPositionRangeQuery.java Tue Sep  8 12:16:06 2015
@@ -18,7 +18,6 @@ package org.apache.lucene.search.spans;
 
 
 import org.apache.lucene.search.spans.FilterSpans.AcceptStatus;
-import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;
 
@@ -70,18 +69,10 @@ public class SpanPositionRangeQuery exte
     buffer.append(", ").append(start).append(", ");
     buffer.append(end);
     buffer.append(")");
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 
   @Override
-  public SpanPositionRangeQuery clone() {
-    SpanPositionRangeQuery result = new SpanPositionRangeQuery((SpanQuery) match.clone(), start, end);
-    result.setBoost(getBoost());
-    return result;
-  }
-
-  @Override
   public boolean equals(Object o) {
     if (! super.equals(o)) {
       return false;

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanQuery.java Tue Sep  8 12:16:06 2015
@@ -22,8 +22,10 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 
@@ -67,4 +69,14 @@ public abstract class SpanQuery extends
     }
     return terms;
   }
+
+  @Override
+  public Query rewrite(IndexReader reader) throws IOException {
+    if (super.getBoost() != 1f) {
+      SpanQuery rewritten = (SpanQuery) clone();
+      rewritten.setBoost(1f);
+      return new SpanBoostQuery(rewritten, super.getBoost());
+    }
+    return this;
+  }
 }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanTermQuery.java Tue Sep  8 12:16:06 2015
@@ -129,7 +129,6 @@ public class SpanTermQuery extends SpanQ
       buffer.append(term.text());
     else
       buffer.append(term.toString());
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java Tue Sep  8 12:16:06 2015
@@ -101,7 +101,7 @@ public abstract class SpanWeight extends
       i++;
     }
     CollectionStatistics collectionStats = searcher.collectionStatistics(query.getField());
-    return this.similarity.computeWeight(query.getBoost(), collectionStats, termStats);
+    return searcher.getSimilarity(true).computeWeight(collectionStats, termStats);
   }
 
   /**
@@ -125,9 +125,9 @@ public abstract class SpanWeight extends
   }
 
   @Override
-  public void normalize(float queryNorm, float topLevelBoost) {
+  public void normalize(float queryNorm, float boost) {
     if (simWeight != null) {
-      simWeight.normalize(queryNorm, topLevelBoost);
+      simWeight.normalize(queryNorm, boost);
     }
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java Tue Sep  8 12:16:06 2015
@@ -27,7 +27,7 @@ import org.apache.lucene.index.TermConte
 import org.apache.lucene.search.IndexSearcher;
 
 /** Keep matches that are contained within another Spans. */
-public class SpanWithinQuery extends SpanContainQuery {
+public final class SpanWithinQuery extends SpanContainQuery {
 
   /** Construct a SpanWithinQuery matching spans from <code>little</code>
    * that are inside of <code>big</code>.
@@ -35,7 +35,7 @@ public class SpanWithinQuery extends Spa
    * <code>big</code> and <code>little</code> must be in the same field.
    */
   public SpanWithinQuery(SpanQuery big, SpanQuery little) {
-    super(big, little, little.getBoost());
+    super(big, little);
   }
 
   @Override
@@ -44,13 +44,6 @@ public class SpanWithinQuery extends Spa
   }
 
   @Override
-  public SpanWithinQuery clone() {
-    return new SpanWithinQuery(
-          (SpanQuery) big.clone(),
-          (SpanQuery) little.clone());
-  }
-
-  @Override
   public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
     SpanWeight bigWeight = big.createWeight(searcher, false);
     SpanWeight littleWeight = little.createWeight(searcher, false);

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/ToStringUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/ToStringUtils.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/ToStringUtils.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/ToStringUtils.java Tue Sep  8 12:16:06 2015
@@ -24,15 +24,6 @@ public final class ToStringUtils {
 
   private ToStringUtils() {} // no instance
 
-  /**
-   * for printing boost only if not 1.0
-   */
-  public static String boost(float boost) {
-    if (boost != 1.0f) {
-      return "^" + Float.toString(boost);
-    } else return "";
-  }
-
   public static void byteArray(StringBuilder buffer, byte[] bytes) {
     for (int i = 0; i < bytes.length; i++) {
       buffer.append("b[").append(i).append("]=").append(bytes[i]);

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/TestSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/TestSearch.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/TestSearch.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/TestSearch.java Tue Sep  8 12:16:06 2015
@@ -34,9 +34,8 @@ import org.apache.lucene.search.*;
 public class TestSearch extends LuceneTestCase {
 
   public void testNegativeQueryBoost() throws Exception {
-    Query q = new TermQuery(new Term("foo", "bar"));
-    q.setBoost(-42f);
-    assertEquals(-42f, q.getBoost(), 0.0f);
+    BoostQuery q = new BoostQuery(new TermQuery(new Term("foo", "bar")), -42f);
+    assertEquals(-42f, q.getBoost(), 0f);
 
     Directory directory = newDirectory();
     try {

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java Tue Sep  8 12:16:06 2015
@@ -110,7 +110,7 @@ public class TestCustomNorms extends Luc
     }
     
     @Override
-    public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+    public SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
       throw new UnsupportedOperationException();
     }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java Tue Sep  8 12:16:06 2015
@@ -187,7 +187,7 @@ public class TestNorms extends LuceneTes
     }
 
     @Override
-    public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+    public SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
       throw new UnsupportedOperationException();
     }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java Tue Sep  8 12:16:06 2015
@@ -105,7 +105,7 @@ public class TestUniqueTermCount extends
     }
 
     @Override
-    public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+    public SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
       throw new UnsupportedOperationException();
     }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java Tue Sep  8 12:16:06 2015
@@ -224,7 +224,7 @@ final class JustCompileSearch {
   static final class JustCompileSimilarity extends Similarity {
 
     @Override
-    public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+    public SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanCoord.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanCoord.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanCoord.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanCoord.java Tue Sep  8 12:16:06 2015
@@ -84,7 +84,7 @@ public class TestBooleanCoord extends Lu
       }
 
       @Override
-      public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+      public SimWeight computeWeight(CollectionStatistics collectionStats, TermStatistics... termStats) {
         return new SimWeight() {
           @Override
           public float getValueForNormalization() {

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java Tue Sep  8 12:16:06 2015
@@ -104,8 +104,7 @@ public class TestBooleanQuery extends Lu
 
     // LUCENE-2617: make sure that a term not in the index still contributes to the score via coord factor
     float score = s.search(q.build(), 10).getMaxScore();
-    Query subQuery = new TermQuery(new Term("field", "not_in_index"));
-    subQuery.setBoost(0);
+    Query subQuery = new BoostQuery(new TermQuery(new Term("field", "not_in_index")), 0f);
     q.add(subQuery, BooleanClause.Occur.SHOULD);
     float score2 = s.search(q.build(), 10).getMaxScore();
     assertEquals(score*.5F, score2, 1e-6);
@@ -116,14 +115,12 @@ public class TestBooleanQuery extends Lu
       qq.add(clause);
     }
     PhraseQuery phrase = new PhraseQuery("field", "not_in_index", "another_not_in_index");
-    phrase.setBoost(0);
-    qq.add(phrase, BooleanClause.Occur.SHOULD);
+    qq.add(new BoostQuery(phrase, 0f), BooleanClause.Occur.SHOULD);
     score2 = s.search(qq.build(), 10).getMaxScore();
     assertEquals(score*(1/3F), score2, 1e-6);
 
     // now test BooleanScorer2
-    subQuery = new TermQuery(new Term("field", "b"));
-    subQuery.setBoost(0);
+    subQuery = new BoostQuery(new TermQuery(new Term("field", "b")), 0f);
     q.add(subQuery, BooleanClause.Occur.MUST);
     score2 = s.search(q.build(), 10).getMaxScore();
     assertEquals(score*(2/3F), score2, 1e-6);
@@ -336,7 +333,6 @@ public class TestBooleanQuery extends Lu
   }
 
   public void testOneClauseRewriteOptimization() throws Exception {
-    final float BOOST = 3.5F;
     final String FIELD = "content";
     final String VALUE = "foo";
 
@@ -345,29 +341,20 @@ public class TestBooleanQuery extends Lu
     IndexReader r = DirectoryReader.open(dir);
 
     TermQuery expected = new TermQuery(new Term(FIELD, VALUE));
-    expected.setBoost(BOOST);
 
     final int numLayers = atLeast(3);
-    boolean needBoost = true;
     Query actual = new TermQuery(new Term(FIELD, VALUE));
 
     for (int i = 0; i < numLayers; i++) {
-      if (needBoost && 0 == TestUtil.nextInt(random(),0,numLayers)) {
-        needBoost = false;
-        actual.setBoost(BOOST);
-      }
 
       BooleanQuery.Builder bq = new BooleanQuery.Builder();
       bq.add(actual, random().nextBoolean()
              ? BooleanClause.Occur.SHOULD : BooleanClause.Occur.MUST);
       actual = bq.build();
     }
-    if (needBoost) {
-      actual.setBoost(BOOST);
-    }
 
     assertEquals(numLayers + ": " + actual.toString(),
-                 expected, actual.rewrite(r));
+                 expected, new IndexSearcher(r).rewrite(actual));
 
     r.close();
     dir.close();
@@ -464,7 +451,6 @@ public class TestBooleanQuery extends Lu
     }
     bq2Builder.setMinimumNumberShouldMatch(bq.getMinimumNumberShouldMatch());
     final BooleanQuery bq2 = bq2Builder.build();
-    bq2.setBoost(bq.getBoost());
 
     final AtomicBoolean matched = new AtomicBoolean();
     searcher.search(bq, new SimpleCollector() {
@@ -517,7 +503,6 @@ public class TestBooleanQuery extends Lu
 
     BooleanQuery.Builder qBuilder = new BooleanQuery.Builder();
     BooleanQuery q = qBuilder.build();
-    q.setBoost(random().nextFloat());
     qBuilder.add(new TermQuery(new Term("field", "a")), Occur.FILTER);
 
     // With a single clause, we will rewrite to the underlying
@@ -528,7 +513,6 @@ public class TestBooleanQuery extends Lu
     // Make sure it returns null scores
     qBuilder.add(new TermQuery(new Term("field", "b")), Occur.FILTER);
     q = qBuilder.build();
-    q.setBoost(random().nextFloat());
     assertSameScoresWithoutFilters(searcher, q);
 
     // Now with a scoring clause, we need to make sure that
@@ -536,7 +520,6 @@ public class TestBooleanQuery extends Lu
     // query
     qBuilder.add(new TermQuery(new Term("field", "c")), Occur.SHOULD);
     q = qBuilder.build();
-    q.setBoost(random().nextFloat());
     assertSameScoresWithoutFilters(searcher, q);
 
     // FILTER and empty SHOULD
@@ -544,7 +527,6 @@ public class TestBooleanQuery extends Lu
     qBuilder.add(new TermQuery(new Term("field", "a")), Occur.FILTER);
     qBuilder.add(new TermQuery(new Term("field", "e")), Occur.SHOULD);
     q = qBuilder.build();
-    q.setBoost(random().nextFloat());
     assertSameScoresWithoutFilters(searcher, q);
 
     // mix of FILTER and MUST
@@ -552,7 +534,6 @@ public class TestBooleanQuery extends Lu
     qBuilder.add(new TermQuery(new Term("field", "a")), Occur.FILTER);
     qBuilder.add(new TermQuery(new Term("field", "d")), Occur.MUST);
     q = qBuilder.build();
-    q.setBoost(random().nextFloat());
     assertSameScoresWithoutFilters(searcher, q);
 
     // FILTER + minShouldMatch
@@ -562,7 +543,6 @@ public class TestBooleanQuery extends Lu
     qBuilder.add(new TermQuery(new Term("field", "d")), Occur.SHOULD);
     qBuilder.setMinimumNumberShouldMatch(1);
     q = qBuilder.build();
-    q.setBoost(random().nextFloat());
     assertSameScoresWithoutFilters(searcher, q);
 
     reader.close();
@@ -587,8 +567,8 @@ public class TestBooleanQuery extends Lu
 
     // Single clauses rewrite to a term query
     final Query rewritten1 = query1.build().rewrite(reader);
-    assertTrue(rewritten1 instanceof ConstantScoreQuery);
-    assertEquals(0f, rewritten1.getBoost(), 0f);
+    assertTrue(rewritten1 instanceof BoostQuery);
+    assertEquals(0f, ((BoostQuery) rewritten1).getBoost(), 0f);
 
     // When there are two clauses, we cannot rewrite, but if one of them creates
     // a null scorer we will end up with a single filter scorer and will need to