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 2017/03/02 18:39:42 UTC
[4/4] lucene-solr:branch_6x: LUCENE-6819: Deprecate index-time boosts.
LUCENE-6819: Deprecate index-time boosts.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/5f8a6dff
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/5f8a6dff
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/5f8a6dff
Branch: refs/heads/branch_6x
Commit: 5f8a6dfff65599d961b99c6ff03b70b79e2ccaf4
Parents: 48f8471
Author: Adrien Grand <jp...@gmail.com>
Authored: Thu Mar 2 19:37:43 2017 +0100
Committer: Adrien Grand <jp...@gmail.com>
Committed: Thu Mar 2 19:37:43 2017 +0100
----------------------------------------------------------------------
lucene/CHANGES.txt | 4 +++
.../java/org/apache/lucene/document/Field.java | 4 +++
.../org/apache/lucene/index/IndexableField.java | 4 +++
solr/CHANGES.txt | 4 +++
.../apache/solr/handler/loader/JsonLoader.java | 18 +++++++++++++
.../apache/solr/handler/loader/XMLLoader.java | 18 +++++++++++++
.../apache/solr/common/SolrInputDocument.java | 27 ++++++++++++++++++++
.../org/apache/solr/common/SolrInputField.java | 14 ++++++++++
8 files changed, 93 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f8a6dff/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 61bc443..3c7e245 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -43,6 +43,10 @@ API Changes
instead of once all shard responses are present. (Simon Willnauer,
Mike McCandless)
+* LUCENE-6819: Index-time boosts are deprecated. As a replacement, index-time
+ scoring factors should be indexed into a doc value field and combined at
+ query time using eg. FunctionScoreQuery. (Adrien Grand)
+
New Features
* LUCENE-7449: Add CROSSES relation support to RangeFieldQuery. (Nick Knize)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f8a6dff/lucene/core/src/java/org/apache/lucene/document/Field.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/document/Field.java b/lucene/core/src/java/org/apache/lucene/document/Field.java
index 8798610..61d7aab 100644
--- a/lucene/core/src/java/org/apache/lucene/document/Field.java
+++ b/lucene/core/src/java/org/apache/lucene/document/Field.java
@@ -453,7 +453,11 @@ public class Field implements IndexableField {
* @throws IllegalArgumentException if this field is not indexed,
* or if it omits norms.
* @see #boost()
+ * @deprecated Index-time boosts are deprecated, please index index-time scoring
+ * factors into a doc value field and combine them with the score at
+ * query time using eg. FunctionScoreQuery.
*/
+ @Deprecated
public void setBoost(float boost) {
if (boost != 1.0f) {
if (type.indexOptions() == IndexOptions.NONE || type.omitNorms()) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f8a6dff/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexableField.java b/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
index f6fc615..7febc12 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
@@ -76,7 +76,11 @@ public interface IndexableField {
*
* @see Similarity#computeNorm(FieldInvertState)
* @see ClassicSimilarity#encodeNormValue(float)
+ * @deprecated Index-time boosts are deprecated, please index index-time scoring
+ * factors into a doc value field and combine them with the score at
+ * query time using eg. FunctionScoreQuery.
*/
+ @Deprecated
public float boost();
/** Non-null if this field has a binary value */
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f8a6dff/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7798e7c..ec44791 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -35,6 +35,10 @@ Detailed Change List
Upgrade Notes
----------------------
+* Index-time boosts are now deprecated. As a replacement, index-time scoring
+ factors should be indexed in a separate field and combined with the query
+ score using a function query.
+
New Features
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f8a6dff/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java b/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
index 2041d2f..e73d5fc 100644
--- a/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
+++ b/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.io.IOUtils;
import org.apache.solr.common.SolrException;
@@ -65,6 +66,7 @@ import static org.apache.solr.common.params.CommonParams.PATH;
*/
public class JsonLoader extends ContentStreamLoader {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final AtomicBoolean WARNED_ABOUT_INDEX_TIME_BOOSTS = new AtomicBoolean();
public static final String CHILD_DOC_KEY = "_childDocuments_";
@Override
@@ -455,6 +457,14 @@ public class JsonLoader extends ContentStreamLoader {
cmd.commitWithin = (int) parser.getLong();
} else if ("boost".equals(key)) {
boost = Float.parseFloat(parser.getNumberChars().toString());
+ String message = "Using document boost: " + boost + " != 1.0 will not be supported anymore in 7.0. "
+ + "Please index scoring factors into a separate field and combine them with the main query's "
+ + "score using function queries.";
+ if (WARNED_ABOUT_INDEX_TIME_BOOSTS.compareAndSet(false, true)) {
+ log.warn(message);
+ } else {
+ log.debug(message);
+ }
} else {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown key '" + key + "' at [" + parser.getPosition() + "]");
}
@@ -574,6 +584,14 @@ public class JsonLoader extends ContentStreamLoader {
}
boost = (float) parser.getDouble();
+ String message = "Using field boost: " + boost + " != 1.0 will not be supported anymore in 7.0. "
+ + "Please index scoring factors into a separate field and combine them with the main query's "
+ + "score using function queries.";
+ if (WARNED_ABOUT_INDEX_TIME_BOOSTS.compareAndSet(false, true)) {
+ log.warn(message);
+ } else {
+ log.debug(message);
+ }
} else if ("value".equals(label)) {
normalFieldValue = parseNormalFieldValue(parser.nextEvent(), sif.getName());
} else {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f8a6dff/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java b/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
index d6a5170..bfedff3 100644
--- a/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
+++ b/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
@@ -35,6 +35,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
import com.google.common.collect.Lists;
import org.apache.commons.io.IOUtils;
@@ -71,6 +72,7 @@ import static org.apache.solr.common.params.CommonParams.NAME;
public class XMLLoader extends ContentStreamLoader {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final AtomicBoolean WARNED_ABOUT_INDEX_TIME_BOOSTS = new AtomicBoolean();
static final XMLErrorLogger xmllog = new XMLErrorLogger(log);
public static final String CONTEXT_TRANSFORMER_KEY = "xsltupdater.transformer";
@@ -379,6 +381,14 @@ public class XMLLoader extends ContentStreamLoader {
for (int i = 0; i < parser.getAttributeCount(); i++) {
attrName = parser.getAttributeLocalName(i);
if ("boost".equals(attrName)) {
+ String message = "Using document boost: " + parser.getAttributeValue(i) + " != 1.0 will not be supported anymore in 7.0. "
+ + "Please index scoring factors into a separate field and combine them with the main query's "
+ + "score using function queries.";
+ if (WARNED_ABOUT_INDEX_TIME_BOOSTS.compareAndSet(false, true)) {
+ log.warn(message);
+ } else {
+ log.debug(message);
+ }
doc.setDocumentBoost(Float.parseFloat(parser.getAttributeValue(i)));
} else {
log.warn("XML element <doc> has invalid XML attr:" + attrName);
@@ -471,6 +481,14 @@ public class XMLLoader extends ContentStreamLoader {
name = attrVal;
} else if ("boost".equals(attrName)) {
boost = Float.parseFloat(attrVal);
+ String message = "Using field boost: " + boost + " != 1.0 will not be supported anymore in 7.0. "
+ + "Please index scoring factors into a separate field and combine them with the main query's "
+ + "score using function queries.";
+ if (WARNED_ABOUT_INDEX_TIME_BOOSTS.compareAndSet(false, true)) {
+ log.warn(message);
+ } else {
+ log.debug(message);
+ }
} else if ("null".equals(attrName)) {
isNull = StrUtils.parseBoolean(attrVal);
} else if ("update".equals(attrName)) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f8a6dff/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java b/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
index 3d3c060..e11aae3 100644
--- a/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
+++ b/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
@@ -131,6 +131,14 @@ public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInpu
setField(name, value, 1.0f );
}
+ /**
+ * Set a field value.
+ * @deprecated Index-time boosts are deprecated. You should instead index
+ * scoring factors into a separate field and combine them with
+ * the main query's score at search time using function queries.
+ * Use {@link #setField(String, Object)} instead.
+ */
+ @Deprecated
public void setField(String name, Object value, float boost )
{
SolrInputField field = new SolrInputField( name );
@@ -150,7 +158,12 @@ public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInpu
* @param name Name of the field, should match one of the field names defined under "fields" tag in schema.xml.
* @param value Value of the field, should be of same class type as defined by "type" attribute of the corresponding field in schema.xml.
* @param boost Boost value for the field
+ * @deprecated Index-time boosts are deprecated. You should instead index
+ * scoring factors into a separate field and combine them with
+ * the main query's score at search time using function queries.
+ * Use {@link #addField(String, Object)} instead.
*/
+ @Deprecated
public void addField(String name, Object value, float boost )
{
SolrInputField field = _fields.get( name );
@@ -187,10 +200,24 @@ public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInpu
return _fields.values().iterator();
}
+ /**
+ * Get the document boost.
+ * @deprecated Index-time boosts are deprecated. You should instead index
+ * scoring factors into a separate field and combine them with
+ * the main query's score at search time using function queries.
+ */
+ @Deprecated
public float getDocumentBoost() {
return _documentBoost;
}
+ /**
+ * Set the document boost.
+ * @deprecated Index-time boosts are deprecated. You should instead index
+ * scoring factors into a separate field and combine them with
+ * the main query's score at search time using function queries.
+ */
+ @Deprecated
public void setDocumentBoost(float documentBoost) {
_documentBoost = documentBoost;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f8a6dff/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
index 261b326..2d19c74 100644
--- a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
+++ b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
@@ -165,10 +165,24 @@ public class SolrInputField implements Iterable<Object>, Serializable
//---------------------------------------------------------------
//---------------------------------------------------------------
+ /**
+ * Get the field's boost.
+ * @deprecated Index-time boosts are deprecated. You should instead index
+ * scoring factors into a separate field and combine them with
+ * the main query's score at search time using function queries.
+ */
+ @Deprecated
public float getBoost() {
return boost;
}
+ /**
+ * Set the field's boost.
+ * @deprecated Index-time boosts are deprecated. You should instead index
+ * scoring factors into a separate field and combine them with
+ * the main query's score at search time using function queries.
+ */
+ @Deprecated
public void setBoost(float boost) {
this.boost = boost;
}