Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-1973: Remove deprecated BoostingTermQuery

Uwe Schindler1b59256ab8a9
diff --git a/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingTermBuilder.java b/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingTermBuilder.java
index 59ca5c47bb7..dfd93048d12 100644
--- a/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingTermBuilder.java
+++ b/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingTermBuilder.java
@@ -3,7 +3,8 @@ package org.apache.lucene.xmlparser.builders;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
-import org.apache.lucene.search.payloads.BoostingTermQuery;
+import org.apache.lucene.search.payloads.PayloadTermQuery;
+import org.apache.lucene.search.payloads.AveragePayloadFunction;
import org.apache.lucene.xmlparser.DOMUtils;
import org.apache.lucene.xmlparser.ParserException;
import org.w3c.dom.Element;
@@ -35,7 +36,7 @@ public class BoostingTermBuilder extends SpanBuilderBase
{
String fieldName=DOMUtils.getAttributeWithInheritanceOrFail(e,"fieldName");
String value=DOMUtils.getNonBlankTextOrFail(e);
- BoostingTermQuery btq = new BoostingTermQuery(new Term(fieldName,value));
+ PayloadTermQuery btq = new PayloadTermQuery(new Term(fieldName,value), new AveragePayloadFunction());
btq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
return btq;
diff --git a/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java b/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java
deleted file mode 100644
index e90df448674..00000000000
--- a/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.apache.lucene.search.payloads;
-
-import java.io.IOException;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.Weight;
-import org.apache.lucene.search.spans.TermSpans;
-
-/**
- * Copyright 2004 The Apache Software Foundation
- * <p/>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * The BoostingTermQuery is very similar to the {@link org.apache.lucene.search.spans.SpanTermQuery} except
- * that it factors in the value of the payload located at each of the positions where the
- * {@link org.apache.lucene.index.Term} occurs.
- * <p>
- * In order to take advantage of this, you must override {@link org.apache.lucene.search.Similarity#scorePayload(String, byte[],int,int)}
- * which returns 1 by default.
- * <p>
- * Payload scores are averaged across term occurrences in the document.
- *
- * @see org.apache.lucene.search.Similarity#scorePayload(String, byte[], int, int)
- *
- * @deprecated See {@link org.apache.lucene.search.payloads.PayloadTermQuery}
- */
-public class BoostingTermQuery extends PayloadTermQuery {
-
- public BoostingTermQuery(Term term) {
- this(term, true);
- }
-
- public BoostingTermQuery(Term term, boolean includeSpanScore) {
- super(term, new AveragePayloadFunction(), includeSpanScore);
- }
-
- public Weight createWeight(Searcher searcher) throws IOException {
- return new BoostingTermWeight(this, searcher);
- }
-
- protected class BoostingTermWeight extends PayloadTermWeight {
-
- public BoostingTermWeight(BoostingTermQuery query, Searcher searcher) throws IOException {
- super(query, searcher);
- }
-
- public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
- return new PayloadTermSpanScorer((TermSpans) query.getSpans(reader), this,
- similarity, reader.norms(query.getField()));
- }
-
- }
-
-
- public boolean equals(Object o) {
- if (!(o instanceof BoostingTermQuery))
- return false;
- BoostingTermQuery other = (BoostingTermQuery) o;
- return (this.getBoost() == other.getBoost())
- && this.term.equals(other.term);
- }
-}