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 [5/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/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/ConstantScoreQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/ConstantScoreQueryBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/ConstantScoreQueryBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/ConstantScoreQueryBuilder.java Tue Sep  8 12:16:06 2015
@@ -4,6 +4,7 @@ import org.apache.lucene.queryparser.xml
 import org.apache.lucene.queryparser.xml.ParserException;
 import org.apache.lucene.queryparser.xml.QueryBuilder;
 import org.apache.lucene.queryparser.xml.QueryBuilderFactory;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.ConstantScoreQuery;
 import org.apache.lucene.search.Query;
 import org.w3c.dom.Element;
@@ -40,7 +41,10 @@ public class ConstantScoreQueryBuilder i
     Element queryElem = DOMUtils.getFirstChildOrFail(e);
 
     Query q = new ConstantScoreQuery(queryFactory.getQuery(queryElem));
-    q.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    if (boost != 1f) {
+      q = new BoostQuery(q, boost);
+    }
     return q;
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java Tue Sep  8 12:16:06 2015
@@ -19,6 +19,7 @@ package org.apache.lucene.queryparser.xm
 import org.apache.lucene.queryparser.xml.DOMUtils;
 import org.apache.lucene.queryparser.xml.ParserException;
 import org.apache.lucene.queryparser.xml.QueryBuilder;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.DisjunctionMaxQuery;
 import org.apache.lucene.search.Query;
 import org.w3c.dom.Element;
@@ -44,7 +45,6 @@ public class DisjunctionMaxQueryBuilder
   public Query getQuery(Element e) throws ParserException {
     float tieBreaker = DOMUtils.getAttribute(e, "tieBreaker", 0.0f); 
     DisjunctionMaxQuery dq = new DisjunctionMaxQuery(tieBreaker);
-    dq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
 
     NodeList nl = e.getChildNodes();
     for (int i = 0; i < nl.getLength(); i++) {
@@ -56,6 +56,11 @@ public class DisjunctionMaxQueryBuilder
       }
     }
 
-    return dq;
+    Query q = dq;
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    if (boost != 1f) {
+      q = new BoostQuery(dq, boost);
+    }
+    return q;
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java Tue Sep  8 12:16:06 2015
@@ -6,6 +6,7 @@ import org.apache.lucene.queryparser.xml
 import org.apache.lucene.queryparser.xml.QueryBuilder;
 import org.apache.lucene.sandbox.queries.FuzzyLikeThisQuery;
 import org.apache.lucene.sandbox.queries.SlowFuzzyQuery;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.Query;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -60,8 +61,12 @@ public class FuzzyLikeThisQueryBuilder i
       fbq.addTerms(value, fieldName, minSimilarity, prefixLength);
     }
 
-    fbq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-    return fbq;
+    Query q = fbq;
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    if (boost != 1f) {
+      q = new BoostQuery(fbq, boost);
+    }
+    return q;
   }
 
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/LikeThisQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/LikeThisQueryBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/LikeThisQueryBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/LikeThisQueryBuilder.java Tue Sep  8 12:16:06 2015
@@ -12,6 +12,7 @@ import org.apache.lucene.analysis.TokenS
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.queries.mlt.MoreLikeThisQuery;
 import org.apache.lucene.queryparser.xml.QueryBuilder;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.queryparser.xml.DOMUtils;
 import org.apache.lucene.queryparser.xml.ParserException;
@@ -98,9 +99,12 @@ public class LikeThisQueryBuilder implem
       mlt.setMinDocFreq(minDocFreq);
     }
 
-    mlt.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-
-    return mlt;
+    Query q = mlt;
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    if (boost != 1f) {
+      q = new BoostQuery(mlt, boost);
+    }
+    return q;
   }
 
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanFirstBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanFirstBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanFirstBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanFirstBuilder.java Tue Sep  8 12:16:06 2015
@@ -1,5 +1,6 @@
 package org.apache.lucene.queryparser.xml.builders;
 
+import org.apache.lucene.search.spans.SpanBoostQuery;
 import org.apache.lucene.search.spans.SpanFirstQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.queryparser.xml.DOMUtils;
@@ -41,8 +42,8 @@ public class SpanFirstBuilder extends Sp
 
     SpanFirstQuery sfq = new SpanFirstQuery(q, end);
 
-    sfq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-    return sfq;
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    return new SpanBoostQuery(sfq, boost);
   }
 
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanNearBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanNearBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanNearBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanNearBuilder.java Tue Sep  8 12:16:06 2015
@@ -1,5 +1,6 @@
 package org.apache.lucene.queryparser.xml.builders;
 
+import org.apache.lucene.search.spans.SpanBoostQuery;
 import org.apache.lucene.search.spans.SpanNearQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.queryparser.xml.DOMUtils;
@@ -49,7 +50,9 @@ public class SpanNearBuilder extends Spa
       }
     }
     SpanQuery[] spanQueries = spans.toArray(new SpanQuery[spans.size()]);
-    return new SpanNearQuery(spanQueries, slop, inOrder);
+    SpanQuery snq = new SpanNearQuery(spanQueries, slop, inOrder);
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    return new SpanBoostQuery(snq, boost);
   }
 
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanNotBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanNotBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanNotBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanNotBuilder.java Tue Sep  8 12:16:06 2015
@@ -1,5 +1,6 @@
 package org.apache.lucene.queryparser.xml.builders;
 
+import org.apache.lucene.search.spans.SpanBoostQuery;
 import org.apache.lucene.search.spans.SpanNotQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.queryparser.xml.DOMUtils;
@@ -46,8 +47,8 @@ public class SpanNotBuilder extends Span
 
     SpanNotQuery snq = new SpanNotQuery(include, exclude);
 
-    snq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-    return snq;
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    return new SpanBoostQuery(snq, boost);
   }
 
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanOrBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanOrBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanOrBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanOrBuilder.java Tue Sep  8 12:16:06 2015
@@ -1,5 +1,6 @@
 package org.apache.lucene.queryparser.xml.builders;
 
+import org.apache.lucene.search.spans.SpanBoostQuery;
 import org.apache.lucene.search.spans.SpanOrQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.queryparser.xml.DOMUtils;
@@ -48,8 +49,8 @@ public class SpanOrBuilder extends SpanB
     }
     SpanQuery[] clauses = clausesList.toArray(new SpanQuery[clausesList.size()]);
     SpanOrQuery soq = new SpanOrQuery(clauses);
-    soq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-    return soq;
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    return new SpanBoostQuery(soq, boost);
   }
 
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanOrTermsBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanOrTermsBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanOrTermsBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanOrTermsBuilder.java Tue Sep  8 12:16:06 2015
@@ -4,6 +4,7 @@ import org.apache.lucene.analysis.Analyz
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.search.spans.SpanBoostQuery;
 import org.apache.lucene.search.spans.SpanOrQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
@@ -60,8 +61,8 @@ public class SpanOrTermsBuilder extends
       }
       ts.end();
       SpanOrQuery soq = new SpanOrQuery(clausesList.toArray(new SpanQuery[clausesList.size()]));
-      soq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-      return soq;
+      float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+      return new SpanBoostQuery(soq, boost);
     }
     catch (IOException ioe) {
       throw new ParserException("IOException parsing value:" + value);

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanQueryBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanQueryBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanQueryBuilder.java Tue Sep  8 12:16:06 2015
@@ -15,6 +15,7 @@ package org.apache.lucene.queryparser.xm
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.queryparser.xml.ParserException;
 import org.apache.lucene.queryparser.xml.QueryBuilder;

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanTermBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanTermBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanTermBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/SpanTermBuilder.java Tue Sep  8 12:16:06 2015
@@ -1,6 +1,7 @@
 package org.apache.lucene.queryparser.xml.builders;
 
 import org.apache.lucene.index.Term;
+import org.apache.lucene.search.spans.SpanBoostQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.queryparser.xml.DOMUtils;
@@ -34,8 +35,8 @@ public class SpanTermBuilder extends Spa
     String value = DOMUtils.getNonBlankTextOrFail(e);
     SpanTermQuery stq = new SpanTermQuery(new Term(fieldName, value));
 
-    stq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-    return stq;
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    return new SpanBoostQuery(stq, boost);
   }
 
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/TermQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/TermQueryBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/TermQueryBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/TermQueryBuilder.java Tue Sep  8 12:16:06 2015
@@ -1,6 +1,7 @@
 package org.apache.lucene.queryparser.xml.builders;
 
 import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.queryparser.xml.DOMUtils;
@@ -33,8 +34,11 @@ public class TermQueryBuilder implements
   public Query getQuery(Element e) throws ParserException {
     String field = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
     String value = DOMUtils.getNonBlankTextOrFail(e);
-    TermQuery tq = new TermQuery(new Term(field, value));
-    tq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
+    Query tq = new TermQuery(new Term(field, value));
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    if (boost != 1f) {
+      tq = new BoostQuery(tq, boost);
+    }
     return tq;
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/TermsQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/TermsQueryBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/TermsQueryBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/TermsQueryBuilder.java Tue Sep  8 12:16:06 2015
@@ -6,6 +6,7 @@ import org.apache.lucene.analysis.tokena
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.util.BytesRef;
@@ -67,8 +68,8 @@ public class TermsQueryBuilder implement
     }
 
     Query q = bq.build();
-    q.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-    return q;
+    float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+    return new BoostQuery(q, boost);
   }
 
 }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/UserInputQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/UserInputQueryBuilder.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/UserInputQueryBuilder.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/UserInputQueryBuilder.java Tue Sep  8 12:16:06 2015
@@ -3,8 +3,8 @@ package org.apache.lucene.queryparser.xm
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.queryparser.classic.QueryParser;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.util.Version;
 import org.apache.lucene.queryparser.xml.DOMUtils;
 import org.apache.lucene.queryparser.xml.ParserException;
 import org.apache.lucene.queryparser.xml.QueryBuilder;
@@ -73,8 +73,8 @@ public class UserInputQueryBuilder imple
         QueryParser parser = createQueryParser(fieldName, analyzer);
         q = parser.parse(text);
       }
-      q.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
-      return q;
+      float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
+      return new BoostQuery(q, boost);
     } catch (ParseException e1) {
       throw new ParserException(e1.getMessage());
     }

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java Tue Sep  8 12:16:06 2015
@@ -88,13 +88,13 @@ public class TestMultiFieldQueryParser e
     assertEquals("+(b:one t:one) -(b:two t:two) -(b:three t:three)", q.toString());
     
     q = mfqp.parse("one^2 two");
-    assertEquals("((b:one t:one)^2.0) (b:two t:two)", q.toString());
+    assertEquals("(b:one t:one)^2.0 (b:two t:two)", q.toString());
 
     q = mfqp.parse("one~ two");
     assertEquals("(b:one~2 t:one~2) (b:two t:two)", q.toString());
 
     q = mfqp.parse("one~0.8 two^2");
-    assertEquals("(b:one~0 t:one~0) ((b:two t:two)^2.0)", q.toString());
+    assertEquals("(b:one~0 t:one~0) (b:two t:two)^2.0", q.toString());
 
     q = mfqp.parse("one* two*");
     assertEquals("(b:one* t:one*) (b:two* t:two*)", q.toString());
@@ -156,7 +156,7 @@ public class TestMultiFieldQueryParser e
       assertEquals("+(b:one^5.0 t:one^10.0) +(b:two^5.0 t:two^10.0) +foo:test", q.toString());
       
       q = mfqp.parse("one^3 AND two^4");
-      assertEquals("+((b:one^5.0 t:one^10.0)^3.0) +((b:two^5.0 t:two^10.0)^4.0)", q.toString());
+      assertEquals("+(b:one^5.0 t:one^10.0)^3.0 +(b:two^5.0 t:two^10.0)^4.0", q.toString());
   }
 
   public void testStaticMethod1() throws ParseException {

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java Tue Sep  8 12:16:06 2015
@@ -32,6 +32,7 @@ import org.apache.lucene.queryparser.fle
 import org.apache.lucene.queryparser.util.QueryParserTestBase;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.MultiPhraseQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
@@ -223,20 +224,22 @@ public class TestQueryParser extends Que
     tq = (TermQuery) qp.parse("foo:zoo*");
     assertEquals("zoo", tq.getTerm().text());
     assertEquals(2, type[0]);
-    
-    tq = (TermQuery) qp.parse("foo:zoo*^2");
+
+    BoostQuery bq = (BoostQuery) qp.parse("foo:zoo*^2");
+    tq = (TermQuery) bq.getQuery();
     assertEquals("zoo", tq.getTerm().text());
     assertEquals(2, type[0]);
-    assertEquals(tq.getBoost(), 2, 0);
+    assertEquals(bq.getBoost(), 2, 0);
     
     tq = (TermQuery) qp.parse("foo:*");
     assertEquals("*", tq.getTerm().text());
     assertEquals(1, type[0]); // could be a valid prefix query in the future too
     
-    tq = (TermQuery) qp.parse("foo:*^2");
+    bq = (BoostQuery) qp.parse("foo:*^2");
+    tq = (TermQuery) bq.getQuery();
     assertEquals("*", tq.getTerm().text());
     assertEquals(1, type[0]);
-    assertEquals(tq.getBoost(), 2, 0);
+    assertEquals(bq.getBoost(), 2, 0);
     
     tq = (TermQuery) qp.parse("*:foo");
     assertEquals("*", tq.getTerm().field());
@@ -341,23 +344,23 @@ public class TestQueryParser extends Que
     qp.setDefaultOperator(Operator.AND);
     assertEquals(expected, qp.parse("dogs"));
     assertEquals(expected, qp.parse("\"dogs\""));
-    expected.setBoost(2.0f);
+    expected = new BoostQuery(expected, 2f);
     assertEquals(expected, qp.parse("dogs^2"));
     assertEquals(expected, qp.parse("\"dogs\"^2"));
   }
   
   /** forms multiphrase query */
   public void testSynonymsPhrase() throws Exception {
-    MultiPhraseQuery expected = new MultiPhraseQuery();
-    expected.add(new Term("field", "old"));
-    expected.add(new Term[] { new Term("field", "dogs"), new Term("field", "dog") });
+    MultiPhraseQuery expectedQ = new MultiPhraseQuery();
+    expectedQ.add(new Term("field", "old"));
+    expectedQ.add(new Term[] { new Term("field", "dogs"), new Term("field", "dog") });
     QueryParser qp = new QueryParser("field", new MockSynonymAnalyzer());
-    assertEquals(expected, qp.parse("\"old dogs\""));
+    assertEquals(expectedQ, qp.parse("\"old dogs\""));
     qp.setDefaultOperator(Operator.AND);
-    assertEquals(expected, qp.parse("\"old dogs\""));
-    expected.setBoost(2.0f);
+    assertEquals(expectedQ, qp.parse("\"old dogs\""));
+    BoostQuery expected = new BoostQuery(expectedQ, 2f);
     assertEquals(expected, qp.parse("\"old dogs\"^2"));
-    expected.setSlop(3);
+    expectedQ.setSlop(3);
     assertEquals(expected, qp.parse("\"old dogs\"~3^2"));
   }
   
@@ -411,7 +414,7 @@ public class TestQueryParser extends Que
     assertEquals(expected, qp.parse("国"));
     qp.setDefaultOperator(Operator.AND);
     assertEquals(expected, qp.parse("国"));
-    expected.setBoost(2.0f);
+    expected = new BoostQuery(expected, 2f);
     assertEquals(expected, qp.parse("国^2"));
   }
   
@@ -427,7 +430,7 @@ public class TestQueryParser extends Que
     Query expected = expectedB.build();
     QueryParser qp = new QueryParser("field", new MockCJKSynonymAnalyzer());
     assertEquals(expected, qp.parse("中国"));
-    expected.setBoost(2.0f);
+    expected = new BoostQuery(expected, 2f);
     assertEquals(expected, qp.parse("中国^2"));
   }
   
@@ -448,7 +451,7 @@ public class TestQueryParser extends Que
     Query expected = expectedB.build();
     QueryParser qp = new QueryParser("field", new MockCJKSynonymAnalyzer());
     assertEquals(expected, qp.parse("中国国"));
-    expected.setBoost(2.0f);
+    expected = new BoostQuery(expected, 2f);
     assertEquals(expected, qp.parse("中国国^2"));
   }
   
@@ -465,7 +468,7 @@ public class TestQueryParser extends Que
     QueryParser qp = new QueryParser("field", new MockCJKSynonymAnalyzer());
     qp.setDefaultOperator(Operator.AND);
     assertEquals(expected, qp.parse("中国"));
-    expected.setBoost(2.0f);
+    expected = new BoostQuery(expected, 2f);
     assertEquals(expected, qp.parse("中国^2"));
   }
   
@@ -487,21 +490,21 @@ public class TestQueryParser extends Que
     QueryParser qp = new QueryParser("field", new MockCJKSynonymAnalyzer());
     qp.setDefaultOperator(Operator.AND);
     assertEquals(expected, qp.parse("中国国"));
-    expected.setBoost(2.0f);
+    expected = new BoostQuery(expected, 2f);
     assertEquals(expected, qp.parse("中国国^2"));
   }
   
   /** forms multiphrase query */
   public void testCJKSynonymsPhrase() throws Exception {
-    MultiPhraseQuery expected = new MultiPhraseQuery();
-    expected.add(new Term("field", "中"));
-    expected.add(new Term[] { new Term("field", "国"), new Term("field", "國")});
+    MultiPhraseQuery expectedQ = new MultiPhraseQuery();
+    expectedQ.add(new Term("field", "中"));
+    expectedQ.add(new Term[] { new Term("field", "国"), new Term("field", "國")});
     QueryParser qp = new QueryParser("field", new MockCJKSynonymAnalyzer());
     qp.setDefaultOperator(Operator.AND);
-    assertEquals(expected, qp.parse("\"中国\""));
-    expected.setBoost(2.0f);
+    assertEquals(expectedQ, qp.parse("\"中国\""));
+    Query expected = new BoostQuery(expectedQ, 2f);
     assertEquals(expected, qp.parse("\"中国\"^2"));
-    expected.setSlop(3);
+    expectedQ.setSlop(3);
     assertEquals(expected, qp.parse("\"中国\"~3^2"));
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/precedence/TestPrecedenceQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/precedence/TestPrecedenceQueryParser.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/precedence/TestPrecedenceQueryParser.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/precedence/TestPrecedenceQueryParser.java Tue Sep  8 12:16:06 2015
@@ -38,6 +38,7 @@ import org.apache.lucene.queryparser.fle
 import org.apache.lucene.queryparser.flexible.standard.parser.ParseException;
 import org.apache.lucene.queryparser.util.QueryParserTestBase; // javadocs
 import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.FuzzyQuery;
 import org.apache.lucene.search.PhraseQuery;
 import org.apache.lucene.search.PrefixQuery;
@@ -304,7 +305,8 @@ public class TestPrecedenceQueryParser e
     assertQueryEquals("term*germ^3", null, "term*germ^3.0");
 
     assertTrue(getQuery("term*", null) instanceof PrefixQuery);
-    assertTrue(getQuery("term*^2", null) instanceof PrefixQuery);
+    assertTrue(getQuery("term*^2", null) instanceof BoostQuery);
+    assertTrue(((BoostQuery) getQuery("term*^2", null)).getQuery() instanceof PrefixQuery);
     assertTrue(getQuery("term~", null) instanceof FuzzyQuery);
     assertTrue(getQuery("term~0.7", null) instanceof FuzzyQuery);
     FuzzyQuery fq = (FuzzyQuery) getQuery("term~0.7", null);
@@ -566,10 +568,10 @@ public class TestPrecedenceQueryParser e
     assertNotNull(q);
     q = qp.parse("\"hello\"^2.0", "field");
     assertNotNull(q);
-    assertEquals(q.getBoost(), (float) 2.0, (float) 0.5);
+    assertEquals(((BoostQuery) q).getBoost(), (float) 2.0, (float) 0.5);
     q = qp.parse("hello^2.0", "field");
     assertNotNull(q);
-    assertEquals(q.getBoost(), (float) 2.0, (float) 0.5);
+    assertEquals(((BoostQuery) q).getBoost(), (float) 2.0, (float) 0.5);
     q = qp.parse("\"on\"^1.0", "field");
     assertNotNull(q);
 

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java Tue Sep  8 12:16:06 2015
@@ -98,13 +98,13 @@ public class TestMultiFieldQPHelper exte
         .toString());
 
     q = mfqp.parse("one^2 two", null);
-    assertEquals("((b:one t:one)^2.0) (b:two t:two)", q.toString());
+    assertEquals("(b:one t:one)^2.0 (b:two t:two)", q.toString());
 
     q = mfqp.parse("one~ two", null);
     assertEquals("(b:one~2 t:one~2) (b:two t:two)", q.toString());
 
     q = mfqp.parse("one~0.8 two^2", null);
-    assertEquals("(b:one~0 t:one~0) ((b:two t:two)^2.0)", q.toString());
+    assertEquals("(b:one~0 t:one~0) (b:two t:two)^2.0", q.toString());
 
     q = mfqp.parse("one* two*", null);
     assertEquals("(b:one* t:one*) (b:two* t:two*)", q.toString());
@@ -173,7 +173,7 @@ public class TestMultiFieldQPHelper exte
         .toString());
 
     q = mfqp.parse("one^3 AND two^4", null);
-    assertEquals("+((b:one^5.0 t:one^10.0)^3.0) +((b:two^5.0 t:two^10.0)^4.0)",
+    assertEquals("+(b:one^5.0 t:one^10.0)^3.0 +(b:two^5.0 t:two^10.0)^4.0",
         q.toString());
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java Tue Sep  8 12:16:06 2015
@@ -57,6 +57,7 @@ import org.apache.lucene.queryparser.fle
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.FuzzyQuery;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.MatchAllDocsQuery;
@@ -400,7 +401,7 @@ public class TestQPHelper extends Lucene
     expectedB.add(new TermQuery(new Term("field", "中")), BooleanClause.Occur.SHOULD);
     expectedB.add(new TermQuery(new Term("field", "国")), BooleanClause.Occur.SHOULD);
     Query expected = expectedB.build();
-    expected.setBoost(0.5f);
+    expected = new BoostQuery(expected, 0.5f);
     assertEquals(expected, getQuery("中国^0.5", analyzer));
   }
   
@@ -417,8 +418,8 @@ public class TestQPHelper extends Lucene
     // individual CJK chars as terms
     SimpleCJKAnalyzer analyzer = new SimpleCJKAnalyzer();
     
-    PhraseQuery expected = new PhraseQuery("field", "中", "国");
-    expected.setBoost(0.5f);
+    Query expected = new PhraseQuery("field", "中", "国");
+    expected = new BoostQuery(expected, 0.5f);
     
     assertEquals(expected, getQuery("\"中国\"^0.5", analyzer));
   }
@@ -508,7 +509,7 @@ public class TestQPHelper extends Lucene
     assertQueryEquals("((a AND b) AND c)", null, "+(+a +b) +c");
     assertQueryEquals("(a AND b) AND c", null, "+(+a +b) +c");
     assertQueryEquals("b !(a AND b)", null, "b -(+a +b)");
-    assertQueryEquals("(a AND b)^4 OR c", null, "((+a +b)^4.0) c");
+    assertQueryEquals("(a AND b)^4 OR c", null, "(+a +b)^4.0 c");
   }
 
   public void testSlop() throws Exception {
@@ -551,7 +552,8 @@ public class TestQPHelper extends Lucene
     assertQueryEquals("term*germ^3", null, "term*germ^3.0");
 
     assertTrue(getQuery("term*", null) instanceof PrefixQuery);
-    assertTrue(getQuery("term*^2", null) instanceof PrefixQuery);
+    assertTrue(getQuery("term*^2", null) instanceof BoostQuery);
+    assertTrue(((BoostQuery) getQuery("term*^2", null)).getQuery() instanceof PrefixQuery);
     assertTrue(getQuery("term~", null) instanceof FuzzyQuery);
     assertTrue(getQuery("term~0.7", null) instanceof FuzzyQuery);
     FuzzyQuery fq = (FuzzyQuery) getQuery("term~0.7", null);
@@ -971,10 +973,10 @@ public class TestQPHelper extends Lucene
     assertNotNull(q);
     q = qp.parse("\"hello\"^2.0", "field");
     assertNotNull(q);
-    assertEquals(q.getBoost(), (float) 2.0, (float) 0.5);
+    assertEquals(((BoostQuery) q).getBoost(), (float) 2.0, (float) 0.5);
     q = qp.parse("hello^2.0", "field");
     assertNotNull(q);
-    assertEquals(q.getBoost(), (float) 2.0, (float) 0.5);
+    assertEquals(((BoostQuery) q).getBoost(), (float) 2.0, (float) 0.5);
     q = qp.parse("\"on\"^1.0", "field");
     assertNotNull(q);
 
@@ -985,7 +987,7 @@ public class TestQPHelper extends Lucene
     // "the" is a stop word so the result is an empty query:
     assertNotNull(q);
     assertEquals("", q.toString());
-    assertEquals(1.0f, q.getBoost(), 0.01f);
+    assertFalse(q instanceof BoostQuery);
   }
 
   public void assertQueryNodeException(String queryString) throws Exception {
@@ -1151,13 +1153,11 @@ public class TestQPHelper extends Lucene
     assertEquals(q, qp.parse("/[a-z][123]/", df));
     qp.setLowercaseExpandedTerms(true);
     assertEquals(q, qp.parse("/[A-Z][123]/", df));
-    q.setBoost(0.5f);
-    assertEquals(q, qp.parse("/[A-Z][123]/^0.5", df));
+    assertEquals(new BoostQuery(q, 0.5f), qp.parse("/[A-Z][123]/^0.5", df));
     qp.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_REWRITE);
     q.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_REWRITE);
-    assertTrue(qp.parse("/[A-Z][123]/^0.5", df) instanceof RegexpQuery);
-    assertEquals(q, qp.parse("/[A-Z][123]/^0.5", df));
-    assertEquals(MultiTermQuery.SCORING_BOOLEAN_REWRITE, ((RegexpQuery)qp.parse("/[A-Z][123]/^0.5", df)).getRewriteMethod());
+    assertEquals(new BoostQuery(q, 0.5f), qp.parse("/[A-Z][123]/^0.5", df));
+    assertEquals(MultiTermQuery.SCORING_BOOLEAN_REWRITE, ((RegexpQuery) (((BoostQuery) qp.parse("/[A-Z][123]/^0.5", df)).getQuery())).getRewriteMethod());
     qp.setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_REWRITE);
     
     Query escaped = new RegexpQuery(new Term("field", "[a-z]\\/[123]"));
@@ -1207,12 +1207,12 @@ public class TestQPHelper extends Lucene
     result = qp.parse(
         "(fieldX:xxxxx OR fieldy:xxxxxxxx)^2 AND (fieldx:the OR fieldy:foo)",
         "a");
-    assertNotNull("result is null and it shouldn't be", result);
-    assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
-    if (VERBOSE)
-      System.out.println("Result: " + result);
-    assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: "
-        + 2, ((BooleanQuery) result).clauses().size() == 2);
+    Query expected = new BooleanQuery.Builder()
+        .add(new TermQuery(new Term("fieldX", "xxxxx")), Occur.SHOULD)
+        .add(new TermQuery(new Term("fieldy", "xxxxxxxx")), Occur.SHOULD)
+        .build();
+    expected = new BoostQuery(expected, 2f);
+    assertEquals(expected, result);
   }
 
   public void testPositionIncrement() throws Exception {

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java Tue Sep  8 12:16:06 2015
@@ -27,6 +27,7 @@ import org.apache.lucene.analysis.MockTo
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.FuzzyQuery;
 import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.MatchNoDocsQuery;
@@ -480,10 +481,10 @@ public class TestSimpleQueryParser exten
     BooleanQuery.Builder expected = new BooleanQuery.Builder();
     expected.setDisableCoord(true);
     Query field0 = new TermQuery(new Term("field0", "foo"));
-    field0.setBoost(5f);
+    field0 = new BoostQuery(field0, 5f);
     expected.add(field0, Occur.SHOULD);
     Query field1 = new TermQuery(new Term("field1", "foo"));
-    field1.setBoost(10f);
+    field1 = new BoostQuery(field1, 10f);
     expected.add(field1, Occur.SHOULD);
 
     Analyzer analyzer = new MockAnalyzer(random());
@@ -501,20 +502,20 @@ public class TestSimpleQueryParser exten
     BooleanQuery.Builder foo = new BooleanQuery.Builder();
     foo.setDisableCoord(true);
     Query field0 = new TermQuery(new Term("field0", "foo"));
-    field0.setBoost(5f);
+    field0 = new BoostQuery(field0, 5f);
     foo.add(field0, Occur.SHOULD);
     Query field1 = new TermQuery(new Term("field1", "foo"));
-    field1.setBoost(10f);
+    field1 = new BoostQuery(field1, 10f);
     foo.add(field1, Occur.SHOULD);
     expected.add(foo.build(), Occur.SHOULD);
 
     BooleanQuery.Builder bar = new BooleanQuery.Builder();
     bar.setDisableCoord(true);
     field0 = new TermQuery(new Term("field0", "bar"));
-    field0.setBoost(5f);
+    field0 = new BoostQuery(field0, 5f);
     bar.add(field0, Occur.SHOULD);
     field1 = new TermQuery(new Term("field1", "bar"));
-    field1.setBoost(10f);
+    field1 = new BoostQuery(field1, 10f);
     bar.add(field1, Occur.SHOULD);
     expected.add(bar.build(), Occur.SHOULD);
 

Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java Tue Sep  8 12:16:06 2015
@@ -290,7 +290,7 @@ public abstract class QueryParserTestBas
     expectedB.add(new TermQuery(new Term("field", "中")), BooleanClause.Occur.SHOULD);
     expectedB.add(new TermQuery(new Term("field", "国")), BooleanClause.Occur.SHOULD);
     Query expected = expectedB.build();
-    expected.setBoost(0.5f);
+    expected = new BoostQuery(expected, 0.5f);
 
     assertEquals(expected, getQuery("中国^0.5", analyzer));
   }
@@ -308,8 +308,8 @@ public abstract class QueryParserTestBas
     // individual CJK chars as terms
     SimpleCJKAnalyzer analyzer = new SimpleCJKAnalyzer();
     
-    PhraseQuery expected = new PhraseQuery("field", "中", "国");
-    expected.setBoost(0.5f);
+    Query expected = new PhraseQuery("field", "中", "国");
+    expected = new BoostQuery(expected, 0.5f);
     
     assertEquals(expected, getQuery("\"中国\"^0.5", analyzer));
   }
@@ -442,7 +442,8 @@ public abstract class QueryParserTestBas
     assertQueryEquals("term*germ^3", null, "term*germ^3.0");
 
     assertTrue(getQuery("term*") instanceof PrefixQuery);
-    assertTrue(getQuery("term*^2") instanceof PrefixQuery);
+    assertTrue(getQuery("term*^2") instanceof BoostQuery);
+    assertTrue(((BoostQuery) getQuery("term*^2")).getQuery() instanceof PrefixQuery);
     assertTrue(getQuery("term~") instanceof FuzzyQuery);
     assertTrue(getQuery("term~0.7") instanceof FuzzyQuery);
     FuzzyQuery fq = (FuzzyQuery)getQuery("term~0.7");
@@ -867,10 +868,10 @@ public abstract class QueryParserTestBas
     assertNotNull(q);
     q = getQuery("\"hello\"^2.0",qp);
     assertNotNull(q);
-    assertEquals(q.getBoost(), (float) 2.0, (float) 0.5);
+    assertEquals(((BoostQuery) q).getBoost(), (float) 2.0, (float) 0.5);
     q = getQuery("hello^2.0",qp);
     assertNotNull(q);
-    assertEquals(q.getBoost(), (float) 2.0, (float) 0.5);
+    assertEquals(((BoostQuery) q).getBoost(), (float) 2.0, (float) 0.5);
     q = getQuery("\"on\"^1.0",qp);
     assertNotNull(q);
 
@@ -880,7 +881,7 @@ public abstract class QueryParserTestBas
     // "the" is a stop word so the result is an empty query:
     assertNotNull(q);
     assertEquals("", q.toString());
-    assertEquals(1.0f, q.getBoost(), 0.01f);
+    assertFalse(q instanceof BoostQuery);
   }
 
   public void assertParseException(String queryString) throws Exception {
@@ -972,13 +973,13 @@ public abstract class QueryParserTestBas
     assertEquals(q, getQuery("/[a-z][123]/",qp));
     qp.setLowercaseExpandedTerms(true);
     assertEquals(q, getQuery("/[A-Z][123]/",qp));
-    q.setBoost(0.5f);
-    assertEquals(q, getQuery("/[A-Z][123]/^0.5",qp));
+    assertEquals(new BoostQuery(q, 0.5f), getQuery("/[A-Z][123]/^0.5",qp));
     qp.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_REWRITE);
     q.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_REWRITE);
-    assertTrue(getQuery("/[A-Z][123]/^0.5",qp) instanceof RegexpQuery);
-    assertEquals(MultiTermQuery.SCORING_BOOLEAN_REWRITE, ((RegexpQuery)getQuery("/[A-Z][123]/^0.5",qp)).getRewriteMethod());
-    assertEquals(q, getQuery("/[A-Z][123]/^0.5",qp));
+    assertTrue(getQuery("/[A-Z][123]/^0.5",qp) instanceof BoostQuery);
+    assertTrue(((BoostQuery) getQuery("/[A-Z][123]/^0.5",qp)).getQuery() instanceof RegexpQuery);
+    assertEquals(MultiTermQuery.SCORING_BOOLEAN_REWRITE, ((RegexpQuery) ((BoostQuery) getQuery("/[A-Z][123]/^0.5",qp)).getQuery()).getRewriteMethod());
+    assertEquals(new BoostQuery(q, 0.5f), getQuery("/[A-Z][123]/^0.5",qp));
     qp.setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_REWRITE);
     
     Query escaped = new RegexpQuery(new Term("field", "[a-z]\\/[123]"));
@@ -1028,6 +1029,8 @@ public abstract class QueryParserTestBas
     assertTrue("result is not a TermQuery", result instanceof TermQuery);
     result = getQuery("(fieldX:xxxxx OR fieldy:xxxxxxxx)^2 AND (fieldx:the OR fieldy:foo)",qp);
     assertNotNull("result is null and it shouldn't be", result);
+    assertTrue("result is not a BoostQuery", result instanceof BoostQuery);
+    result = ((BoostQuery) result).getQuery();
     assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
     if (VERBOSE) System.out.println("Result: " + result);
     assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: " + 2, ((BooleanQuery) result).clauses().size() == 2);
@@ -1269,8 +1272,8 @@ public abstract class QueryParserTestBas
     assertEquals(new MatchAllDocsQuery(), getQuery(new MatchAllDocsQuery().toString(),qp));
 
     // test parsing with non-default boost
-    MatchAllDocsQuery query = new MatchAllDocsQuery();
-    query.setBoost(2.3f);
+    Query query = new MatchAllDocsQuery();
+    query = new BoostQuery(query, 2.3f);
     assertEquals(query, getQuery(query.toString(),qp));
     setDefaultField(oldDefaultField);
   }

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInBBoxQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInBBoxQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInBBoxQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInBBoxQuery.java Tue Sep  8 12:16:06 2015
@@ -17,12 +17,15 @@ package org.apache.lucene.bkdtree;
  * limitations under the License.
  */
 
+import java.io.IOException;
+
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.SortedNumericDocValues;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.ConstantScoreQuery;
 import org.apache.lucene.search.ConstantScoreScorer;
 import org.apache.lucene.search.ConstantScoreWeight;
 import org.apache.lucene.search.DocIdSet;
@@ -31,9 +34,6 @@ import org.apache.lucene.search.IndexSea
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
-import org.apache.lucene.util.ToStringUtils;
-
-import java.io.IOException;
 
 /** Finds all previously indexed points that fall within the specified boundings box.
  *
@@ -105,6 +105,9 @@ public class BKDPointInBBoxQuery extends
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     // Crosses date line: we just rewrite into OR of two bboxes:
     if (maxLon < minLon) {
 
@@ -114,14 +117,12 @@ public class BKDPointInBBoxQuery extends
 
       // E.g.: maxLon = -179, minLon = 179
       BKDPointInBBoxQuery left = new BKDPointInBBoxQuery(field, minLat, maxLat, BKDTreeWriter.MIN_LON_INCL, maxLon);
-      left.setBoost(getBoost());
       q.add(new BooleanClause(left, BooleanClause.Occur.SHOULD));
       BKDPointInBBoxQuery right = new BKDPointInBBoxQuery(field, minLat, maxLat, minLon, BKDTreeWriter.MAX_LON_INCL);
-      right.setBoost(getBoost());
       q.add(new BooleanClause(right, BooleanClause.Occur.SHOULD));
-      return q.build();
+      return new ConstantScoreQuery(q.build());
     } else {
-      return this;
+      return super.rewrite(reader);
     }
   }
 
@@ -170,7 +171,6 @@ public class BKDPointInBBoxQuery extends
         .append(',')
         .append(maxLat)
         .append("]")
-        .append(ToStringUtils.boost(getBoost()))
         .toString();
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInPolygonQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInPolygonQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInPolygonQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInPolygonQuery.java Tue Sep  8 12:16:06 2015
@@ -17,23 +17,21 @@ package org.apache.lucene.bkdtree;
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.Arrays;
+
 import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.SortedNumericDocValues;
-import org.apache.lucene.index.Term;
+import org.apache.lucene.search.ConstantScoreScorer;
+import org.apache.lucene.search.ConstantScoreWeight;
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.GeoUtils;
-import org.apache.lucene.util.ToStringUtils;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Set;
 
 /** Finds all previously indexed points that fall within the specified polygon.
  *
@@ -109,38 +107,7 @@ public class BKDPointInPolygonQuery exte
     // TODO: except that the polygon verify is costly!  The approximation should be all docs in all overlapping cells, and matches() should
     // then check the polygon
 
-    return new Weight(this) {
-      private float queryNorm;
-      private float queryWeight;
-
-      @Override
-      public void extractTerms(Set<Term> terms) {
-      }
-
-      @Override
-      public float getValueForNormalization() throws IOException {
-        queryWeight = getBoost();
-        return queryWeight * queryWeight;
-      }
-
-      @Override
-      public void normalize(float norm, float topLevelBoost) {
-        queryNorm = norm * topLevelBoost;
-        queryWeight *= queryNorm;
-      }
-
-      @Override
-      public Explanation explain(LeafReaderContext context, int doc) throws IOException {
-        final Scorer s = scorer(context);
-        final boolean exists = s != null && s.advance(doc) == doc;
-
-        if (exists) {
-          return Explanation.match(queryWeight, BKDPointInPolygonQuery.this.toString() + ", product of:",
-              Explanation.match(getBoost(), "boost"), Explanation.match(queryNorm, "queryNorm"));
-        } else {
-          return Explanation.noMatch(BKDPointInPolygonQuery.this.toString() + " doesn't match id " + doc);
-        }
-      }
+    return new ConstantScoreWeight(this) {
 
       @Override
       public Scorer scorer(LeafReaderContext context) throws IOException {
@@ -182,38 +149,7 @@ public class BKDPointInPolygonQuery exte
 
         final DocIdSetIterator disi = result.iterator();
 
-        return new Scorer(this) {
-
-          @Override
-          public float score() throws IOException {
-            return queryWeight;
-          }
-
-          @Override
-          public int freq() throws IOException {
-            return 1;
-          }
-
-          @Override
-          public int docID() {
-            return disi.docID();
-          }
-
-          @Override
-          public int nextDoc() throws IOException {
-            return disi.nextDoc();
-          }
-
-          @Override
-          public int advance(int target) throws IOException {
-            return disi.advance(target);
-          }
-
-          @Override
-          public long cost() {
-            return disi.cost();
-          }
-        };
+        return new ConstantScoreScorer(this, score(), disi);
       }
     };
   }
@@ -263,7 +199,6 @@ public class BKDPointInPolygonQuery exte
         .append(polyLats[i])
         .append("] ");
     }
-    sb.append(ToStringUtils.boost(getBoost()));
     return sb.toString();
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/rangetree/NumericRangeTreeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/rangetree/NumericRangeTreeQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/rangetree/NumericRangeTreeQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/rangetree/NumericRangeTreeQuery.java Tue Sep  8 12:16:06 2015
@@ -29,7 +29,6 @@ import org.apache.lucene.search.IndexSea
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
-import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;
 
@@ -153,7 +152,6 @@ public class NumericRangeTreeQuery exten
       .append(" TO ")
       .append((maxValue == null) ? "*" : maxValue.toString())
       .append(maxInclusive ? ']' : '}')
-      .append(ToStringUtils.boost(getBoost()))
       .toString();
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/rangetree/SortedSetRangeTreeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/rangetree/SortedSetRangeTreeQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/rangetree/SortedSetRangeTreeQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/rangetree/SortedSetRangeTreeQuery.java Tue Sep  8 12:16:06 2015
@@ -32,7 +32,6 @@ import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;
 
@@ -213,7 +212,6 @@ public class SortedSetRangeTreeQuery ext
       .append(" TO ")
       .append((maxValue == null) ? "*" : maxValue.toString())
       .append(maxInclusive ? ']' : '}')
-      .append(ToStringUtils.boost(getBoost()))
       .toString();
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/FuzzyLikeThisQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/FuzzyLikeThisQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/FuzzyLikeThisQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/FuzzyLikeThisQuery.java Tue Sep  8 12:16:06 2015
@@ -68,11 +68,9 @@ public class FuzzyLikeThisQuery extends
     // the rewrite method can 'average' the TermContext's term statistics (docfreq,totalTermFreq) 
     // provided to TermQuery, so that the general idea is agnostic to any scoring system...
     static TFIDFSimilarity sim=new DefaultSimilarity();
-    Query rewrittenQuery=null;
     ArrayList<FieldVals> fieldVals=new ArrayList<>();
     Analyzer analyzer;
-    
-    ScoreTermQueue q;
+
     int MAX_VARIANTS_PER_TERM=50;
     boolean ignoreTF=false;
     private int maxNumTerms;
@@ -125,7 +123,6 @@ public class FuzzyLikeThisQuery extends
      */
     public FuzzyLikeThisQuery(int maxNumTerms, Analyzer analyzer)
     {
-        q=new ScoreTermQueue(maxNumTerms);
         this.analyzer=analyzer;
         this.maxNumTerms = maxNumTerms;
     }
@@ -200,7 +197,7 @@ public class FuzzyLikeThisQuery extends
     }
 
 
-  private void addTerms(IndexReader reader, FieldVals f) throws IOException {
+  private void addTerms(IndexReader reader, FieldVals f, ScoreTermQueue q) throws IOException {
     if (f.queryString == null) return;
     final Terms terms = MultiFields.getTerms(reader, f.fieldName);
     if (terms == null) {
@@ -289,20 +286,16 @@ public class FuzzyLikeThisQuery extends
   @Override
     public Query rewrite(IndexReader reader) throws IOException
     {
-        if(rewrittenQuery!=null)
-        {
-            return rewrittenQuery;
+        if (getBoost() != 1f) {
+          return super.rewrite(reader);
         }
+        ScoreTermQueue q = new ScoreTermQueue(maxNumTerms);
         //load up the list of possible terms
-        for (Iterator<FieldVals> iter = fieldVals.iterator(); iter.hasNext(); ) {
-          FieldVals f = iter.next();
-          addTerms(reader, f);
+        for (FieldVals f : fieldVals) {
+          addTerms(reader, f, q);
         }
-      //clear the list of fields
-        fieldVals.clear();
-        
-        BooleanQuery.Builder bq=new BooleanQuery.Builder();
         
+        BooleanQuery.Builder bq = new BooleanQuery.Builder();
         
         //create BooleanQueries to hold the variants for each token/field pair and ensure it
         // has no coord factor
@@ -350,10 +343,7 @@ public class FuzzyLikeThisQuery extends
         }
         //TODO possible alternative step 3 - organize above booleans into a new layer of field-based
         // booleans with a minimum-should-match of NumFields-1?
-        Query q = bq.build();
-        q.setBoost(getBoost());
-        this.rewrittenQuery=q;
-        return q;
+        return bq.build();
     }
     
     //Holds info for a fuzzy term variant - initially score is set to edit distance (for ranking best

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SlowFuzzyQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SlowFuzzyQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SlowFuzzyQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SlowFuzzyQuery.java Tue Sep  8 12:16:06 2015
@@ -27,7 +27,6 @@ import org.apache.lucene.search.BooleanQ
 import org.apache.lucene.search.FuzzyQuery; // javadocs
 import org.apache.lucene.search.MultiTermQuery;
 import org.apache.lucene.util.AttributeSource;
-import org.apache.lucene.util.ToStringUtils;
 import org.apache.lucene.util.automaton.LevenshteinAutomata;
 
 /** Implements the classic fuzzy search query. The similarity measurement
@@ -166,7 +165,6 @@ public class SlowFuzzyQuery extends Mult
     buffer.append(term.text());
     buffer.append('~');
     buffer.append(Float.toString(minimumSimilarity));
-    buffer.append(ToStringUtils.boost(getBoost()));
     return buffer.toString();
   }
   

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

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesNumbersQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesNumbersQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesNumbersQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesNumbersQuery.java Tue Sep  8 12:16:06 2015
@@ -73,7 +73,7 @@ public class DocValuesNumbersQuery exten
 
   @Override
   public int hashCode() {
-    return Objects.hash(field, numbers, getBoost());
+    return 31 * super.hashCode() + Objects.hash(field, numbers);
   }
 
   @Override

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesRangeQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesRangeQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesRangeQuery.java Tue Sep  8 12:16:06 2015
@@ -28,7 +28,6 @@ import org.apache.lucene.index.SortedNum
 import org.apache.lucene.index.SortedSetDocValues;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.ToStringUtils;
 
 /**
  * A range query that works on top of the doc values APIs. Such queries are
@@ -81,7 +80,7 @@ public final class DocValuesRangeQuery e
 
   @Override
   public boolean equals(Object obj) {
-    if (obj instanceof DocValuesRangeQuery == false) {
+    if (super.equals(obj) == false) {
       return false;
     }
     final DocValuesRangeQuery that = (DocValuesRangeQuery) obj;
@@ -95,7 +94,7 @@ public final class DocValuesRangeQuery e
 
   @Override
   public int hashCode() {
-    return Objects.hash(field, lowerVal, upperVal, includeLower, includeUpper, getBoost());
+    return 31 * super.hashCode() + Objects.hash(field, lowerVal, upperVal, includeLower, includeUpper);
   }
 
   @Override
@@ -109,18 +108,18 @@ public final class DocValuesRangeQuery e
     sb.append(" TO ");
     sb.append(upperVal == null ? "*" : upperVal.toString());
     sb.append(includeUpper ? ']' : '}');
-    sb.append(ToStringUtils.boost(getBoost()));
     return sb.toString();
   }
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     if (lowerVal == null && upperVal == null) {
-      final FieldValueQuery rewritten = new FieldValueQuery(field);
-      rewritten.setBoost(getBoost());
-      return rewritten;
+      return new FieldValueQuery(field);
     }
-    return this;
+    return super.rewrite(reader);
   }
 
   @Override

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesTermsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesTermsQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesTermsQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/DocValuesTermsQuery.java Tue Sep  8 12:16:06 2015
@@ -121,13 +121,10 @@ public class DocValuesTermsQuery extends
 
   @Override
   public boolean equals(Object obj) {
-    if (obj instanceof DocValuesTermsQuery == false) {
+    if (super.equals(obj) == false) {
       return false;
     }
     DocValuesTermsQuery that = (DocValuesTermsQuery) obj;
-    if (!super.equals(obj)) {
-      return false;
-    }
     if (!field.equals(that.field)) {
       return false;
     }
@@ -136,7 +133,7 @@ public class DocValuesTermsQuery extends
 
   @Override
   public int hashCode() {
-    return Objects.hash(field, Arrays.asList(terms), getBoost());
+    return 31 * super.hashCode() + Objects.hash(field, Arrays.asList(terms));
   }
 
   @Override

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java Tue Sep  8 12:16:06 2015
@@ -17,10 +17,11 @@ package org.apache.lucene.search;
  * limitations under the License.
  */
 
+import java.io.IOException;
+
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.util.GeoProjectionUtils;
 import org.apache.lucene.util.GeoUtils;
-import org.apache.lucene.util.ToStringUtils;
 
 /** Implements a simple point distance query on a GeoPoint field. This is based on
  * {@link org.apache.lucene.search.GeoPointInBBoxQuery} and is implemented using a two phase approach. First,
@@ -68,17 +69,18 @@ public final class GeoPointDistanceQuery
   }
 
   @Override
-  public Query rewrite(IndexReader reader) {
+  public Query rewrite(IndexReader reader) throws IOException {
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     if (maxLon < minLon) {
       BooleanQuery.Builder bq = new BooleanQuery.Builder();
 
       GeoPointDistanceQueryImpl left = new GeoPointDistanceQueryImpl(field, this, new GeoBoundingBox(-180.0D, maxLon,
           minLat, maxLat));
-      left.setBoost(getBoost());
       bq.add(new BooleanClause(left, BooleanClause.Occur.SHOULD));
       GeoPointDistanceQueryImpl right = new GeoPointDistanceQueryImpl(field, this, new GeoBoundingBox(minLon, 180.0D,
           minLat, maxLat));
-      right.setBoost(getBoost());
       bq.add(new BooleanClause(right, BooleanClause.Occur.SHOULD));
       return bq.build();
     }
@@ -151,7 +153,6 @@ public final class GeoPointDistanceQuery
         .append(',')
         .append(maxLat)
         .append("]")
-        .append(ToStringUtils.boost(getBoost()))
         .toString();
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInBBoxQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInBBoxQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInBBoxQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInBBoxQuery.java Tue Sep  8 12:16:06 2015
@@ -17,8 +17,9 @@ package org.apache.lucene.search;
  * limitations under the License.
  */
 
+import java.io.IOException;
+
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.util.ToStringUtils;
 
 /** Implements a simple bounding box query on a GeoPoint field. This is inspired by
  * {@link org.apache.lucene.search.NumericRangeQuery} and is implemented using a
@@ -55,15 +56,16 @@ public class GeoPointInBBoxQuery extends
   }
 
   @Override
-  public Query rewrite(IndexReader reader) {
+  public Query rewrite(IndexReader reader) throws IOException {
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     if (maxLon < minLon) {
       BooleanQuery.Builder bq = new BooleanQuery.Builder();
 
       GeoPointInBBoxQueryImpl left = new GeoPointInBBoxQueryImpl(field, -180.0D, minLat, maxLon, maxLat);
-      left.setBoost(getBoost());
       bq.add(new BooleanClause(left, BooleanClause.Occur.SHOULD));
       GeoPointInBBoxQueryImpl right = new GeoPointInBBoxQueryImpl(field, minLon, minLat, 180.0D, maxLat);
-      right.setBoost(getBoost());
       bq.add(new BooleanClause(right, BooleanClause.Occur.SHOULD));
       return bq.build();
     }
@@ -90,7 +92,6 @@ public class GeoPointInBBoxQuery extends
         .append(',')
         .append(maxLat)
         .append("]")
-        .append(ToStringUtils.boost(getBoost()))
         .toString();
   }
 

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInBBoxQueryImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInBBoxQueryImpl.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInBBoxQueryImpl.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInBBoxQueryImpl.java Tue Sep  8 12:16:06 2015
@@ -138,7 +138,6 @@ class GeoPointInBBoxQueryImpl extends Ge
         .append(',')
         .append(maxLat)
         .append("]")
-        .append(ToStringUtils.boost(getBoost()))
         .toString();
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java Tue Sep  8 12:16:06 2015
@@ -139,7 +139,6 @@ public final class GeoPointInPolygonQuer
         .append(y[i])
         .append("] ");
     }
-    sb.append(ToStringUtils.boost(getBoost()));
 
     return sb.toString();
   }

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQuery.java Tue Sep  8 12:16:06 2015
@@ -63,9 +63,7 @@ abstract class GeoPointTermQuery extends
   public static final RewriteMethod GEO_CONSTANT_SCORE_REWRITE = new RewriteMethod() {
     @Override
     public Query rewrite(IndexReader reader, MultiTermQuery query) {
-      Query result = new GeoPointTermQueryConstantScoreWrapper<>((GeoPointTermQuery)query);
-      result.setBoost(query.getBoost());
-      return result;
+      return new GeoPointTermQueryConstantScoreWrapper<>((GeoPointTermQuery)query);
     }
   };
 

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java Tue Sep  8 12:16:06 2015
@@ -51,7 +51,7 @@ final class GeoPointTermQueryConstantSco
       return false;
     }
     final GeoPointTermQueryConstantScoreWrapper<?> that = (GeoPointTermQueryConstantScoreWrapper<?>) o;
-    return this.query.equals(that.query) && this.getBoost() == that.getBoost();
+    return this.query.equals(that.query);
   }
 
   @Override

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java Tue Sep  8 12:16:06 2015
@@ -350,8 +350,7 @@ public class TermAutomatonQuery extends
         }
       }
 
-      stats = similarity.computeWeight(getBoost(),
-                                       searcher.collectionStatistics(field),
+      stats = similarity.computeWeight(searcher.collectionStatistics(field),
                                        allTermStats.toArray(new TermStatistics[allTermStats.size()]));
     }
 
@@ -375,8 +374,8 @@ public class TermAutomatonQuery extends
     }
 
     @Override
-    public void normalize(float queryNorm, float topLevelBoost) {
-      stats.normalize(queryNorm, topLevelBoost);
+    public void normalize(float queryNorm, float boost) {
+      stats.normalize(queryNorm, boost);
     }
 
     @Override

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesNumbersQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesNumbersQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesNumbersQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesNumbersQuery.java Tue Sep  8 12:16:06 2015
@@ -94,19 +94,15 @@ public class TestDocValuesNumbersQuery e
         for (Long number : queryNumbers) {
           bq.add(new TermQuery(new Term("text", number.toString())), Occur.SHOULD);
         }
-        Query q1 = new ConstantScoreQuery(bq.build());
-        q1.setBoost(boost);
+        Query q1 = new BoostQuery(new ConstantScoreQuery(bq.build()), boost);
 
-        Query q2 = new DocValuesNumbersQuery("long", queryNumbers);
-        q2.setBoost(boost);
+        Query q2 = new BoostQuery(new DocValuesNumbersQuery("long", queryNumbers), boost);
         assertSameMatches(searcher, q1, q2, true);
 
-        Query q3 = new DocValuesNumbersQuery("twolongs", queryNumbers);
-        q3.setBoost(boost);
+        Query q3 = new BoostQuery(new DocValuesNumbersQuery("twolongs", queryNumbers), boost);
         assertSameMatches(searcher, q1, q3, true);
 
-        Query q4 = new DocValuesNumbersQuery("twolongs", queryNumbersX2);
-        q4.setBoost(boost);
+        Query q4 = new BoostQuery(new DocValuesNumbersQuery("twolongs", queryNumbersX2), boost);
         assertSameMatches(searcher, q1, q4, true);
       }
 
@@ -158,10 +154,8 @@ public class TestDocValuesNumbersQuery e
         for (Long number : queryNumbers) {
           bq.add(new TermQuery(new Term("text", number.toString())), Occur.SHOULD);
         }
-        Query q1 = new ConstantScoreQuery(bq.build());
-        q1.setBoost(boost);
-        final Query q2 = new DocValuesNumbersQuery("long", queryNumbers);
-        q2.setBoost(boost);
+        Query q1 = new BoostQuery(new ConstantScoreQuery(bq.build()), boost);
+        final Query q2 = new BoostQuery(new DocValuesNumbersQuery("long", queryNumbers), boost);
 
         BooleanQuery.Builder bq1 = new BooleanQuery.Builder();
         bq1.add(q1, Occur.MUST);

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesRangeQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesRangeQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesRangeQuery.java Tue Sep  8 12:16:06 2015
@@ -156,16 +156,12 @@ public class TestDocValuesRangeQuery ext
 
       final float boost = random().nextFloat() * 10;
 
-      final Query q1 = DocValuesRangeQuery.newLongRange("dv1", min, max, minInclusive, maxInclusive);
-      q1.setBoost(boost);
-      final ConstantScoreQuery csq1 = new ConstantScoreQuery(DocValuesRangeQuery.newLongRange("dv1", min, max, minInclusive, maxInclusive));
-      csq1.setBoost(boost);
+      final Query q1 = new BoostQuery(DocValuesRangeQuery.newLongRange("dv1", min, max, minInclusive, maxInclusive), boost);
+      final Query csq1 = new BoostQuery(new ConstantScoreQuery(DocValuesRangeQuery.newLongRange("dv1", min, max, minInclusive, maxInclusive)), boost);
       assertSameMatches(searcher, q1, csq1, true);
 
-      final Query q2 = DocValuesRangeQuery.newBytesRefRange("dv2", toSortableBytes(min), toSortableBytes(max), minInclusive, maxInclusive);
-      q2.setBoost(boost);
-      final ConstantScoreQuery csq2 = new ConstantScoreQuery(DocValuesRangeQuery.newBytesRefRange("dv2", toSortableBytes(min), toSortableBytes(max), minInclusive, maxInclusive));
-      csq2.setBoost(boost);
+      final Query q2 = new BoostQuery(DocValuesRangeQuery.newBytesRefRange("dv2", toSortableBytes(min), toSortableBytes(max), minInclusive, maxInclusive), boost);
+      final Query csq2 = new BoostQuery(new ConstantScoreQuery(DocValuesRangeQuery.newBytesRefRange("dv2", toSortableBytes(min), toSortableBytes(max), minInclusive, maxInclusive)), boost);
       assertSameMatches(searcher, q2, csq2, true);
     }
 

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesTermsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesTermsQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesTermsQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesTermsQuery.java Tue Sep  8 12:16:06 2015
@@ -88,14 +88,12 @@ public class TestDocValuesTermsQuery ext
         for (Term term : queryTerms) {
           bq.add(new TermQuery(term), Occur.SHOULD);
         }
-        Query q1 = new ConstantScoreQuery(bq.build());
-        q1.setBoost(boost);
+        Query q1 = new BoostQuery(new ConstantScoreQuery(bq.build()), boost);
         List<String> bytesTerms = new ArrayList<>();
         for (Term term : queryTerms) {
           bytesTerms.add(term.text());
         }
-        final Query q2 = new DocValuesTermsQuery("f", bytesTerms.toArray(new String[0]));
-        q2.setBoost(boost);
+        final Query q2 = new BoostQuery(new DocValuesTermsQuery("f", bytesTerms.toArray(new String[0])), boost);
         assertSameMatches(searcher, q1, q2, true);
       }
 
@@ -200,14 +198,12 @@ public class TestDocValuesTermsQuery ext
         for (Term term : queryTerms) {
           bq.add(new TermQuery(term), Occur.SHOULD);
         }
-        Query q1 = new ConstantScoreQuery(bq.build());
-        q1.setBoost(boost);
+        Query q1 = new BoostQuery(new ConstantScoreQuery(bq.build()), boost);
         List<String> bytesTerms = new ArrayList<>();
         for (Term term : queryTerms) {
           bytesTerms.add(term.text());
         }
-        final Query q2 = new DocValuesTermsQuery("f", bytesTerms.toArray(new String[0]));
-        q2.setBoost(boost);
+        final Query q2 = new BoostQuery(new DocValuesTermsQuery("f", bytesTerms.toArray(new String[0])), boost);
 
         BooleanQuery.Builder bq1 = new BooleanQuery.Builder();
         bq1.add(q1, Occur.MUST);

Modified: lucene/dev/branches/branch_5x/lucene/spatial/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java Tue Sep  8 12:16:06 2015
@@ -51,11 +51,14 @@ public class CompositeVerifyQuery extend
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     final Query rewritten = indexQuery.rewrite(reader);
     if (rewritten != indexQuery) {
       return new CompositeVerifyQuery(rewritten, predicateValueSource);
     }
-    return this;
+    return super.rewrite(reader);
   }
 
   @Override

Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java Tue Sep  8 12:16:06 2015
@@ -34,7 +34,6 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.ToStringUtils;
 
 import java.io.IOException;
 
@@ -218,7 +217,6 @@ public class PointInGeo3DShapeQuery exte
     sb.append(planetModel);
     sb.append(" Shape: ");
     sb.append(shape);
-    sb.append(ToStringUtils.boost(getBoost()));
     return sb.toString();
   }
 }

Modified: lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java (original)
+++ lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java Tue Sep  8 12:16:06 2015
@@ -38,6 +38,7 @@ import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.BoostQuery;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
@@ -417,8 +418,7 @@ public class SpellChecker implements jav
    */
   private static void add(BooleanQuery.Builder q, String name, String value, float boost) {
     Query tq = new TermQuery(new Term(name, value));
-    tq.setBoost(boost);
-    q.add(new BooleanClause(tq, BooleanClause.Occur.SHOULD));
+    q.add(new BooleanClause(new BoostQuery(tq, boost), BooleanClause.Occur.SHOULD));
   }
 
   /**

Modified: lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionQuery.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionQuery.java Tue Sep  8 12:16:06 2015
@@ -95,6 +95,9 @@ public abstract class CompletionQuery ex
 
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
+    if (getBoost() != 1f) {
+      return super.rewrite(reader);
+    }
     byte type = 0;
     boolean first = true;
     Terms terms;
@@ -132,7 +135,7 @@ public abstract class CompletionQuery ex
         }
       }
     }
-    return this;
+    return super.rewrite(reader);
   }
 
   @Override

Modified: lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionWeight.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionWeight.java?rev=1701783&r1=1701782&r2=1701783&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionWeight.java (original)
+++ lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionWeight.java Tue Sep  8 12:16:06 2015
@@ -150,6 +150,6 @@ public class CompletionWeight extends We
   }
 
   @Override
-  public void normalize(float norm, float topLevelBoost) {
+  public void normalize(float norm, float boost) {
   }
 }

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