Apache Solr open-source search software
SOLR-13138: remove deprecated LegacyBM25SimilarityFactory (#274)
Christine Poerschke3a5e8ce35082
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 2d1e1b4039a..744c63bdac0 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -355,6 +355,8 @@ Other Changes* SOLR-15606: Rename (deprecated) Insanity.java to NumericHidingLeafReader.java adjusting callers to match. (Christine Poerschke)+* SOLR-13138: Remove deprecated LegacyBM25SimilarityFactory class. (Christine Poerschke, janhoy)+Bug Fixes---------------------* SOLR-14546: Fix for a relatively hard to hit issue in OverseerTaskProcessor that could lead to out of order executiondiff --git a/solr/core/src/java/org/apache/solr/search/similarities/BM25SimilarityFactory.java b/solr/core/src/java/org/apache/solr/search/similarities/BM25SimilarityFactory.javaindex 944be035e3e..2a01d280450 100644--- a/solr/core/src/java/org/apache/solr/search/similarities/BM25SimilarityFactory.java+++ b/solr/core/src/java/org/apache/solr/search/similarities/BM25SimilarityFactory.java@@ -23,9 +23,6 @@ import org.apache.solr.schema.SimilarityFactory;/*** Factory for BM25Similarity. This is the default similarity since 8.x.- * If you need the exact same formula as in 6.x and 7.x you should instead look at- * {@link LegacyBM25SimilarityFactory} noting that it is deprecated as of 8.10.0- * and will be removed in 9.x.* <p>* Parameters:* <ul>diff --git a/solr/core/src/java/org/apache/solr/search/similarities/LegacyBM25SimilarityFactory.java b/solr/core/src/java/org/apache/solr/search/similarities/LegacyBM25SimilarityFactory.javadeleted file mode 100644index e4260877080..00000000000--- a/solr/core/src/java/org/apache/solr/search/similarities/LegacyBM25SimilarityFactory.java+++ /dev/null@@ -1,61 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You 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- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * 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.- */-package org.apache.solr.search.similarities;--import org.apache.lucene.search.similarities.Similarity;-import org.apache.lucene.misc.search.similarity.LegacyBM25Similarity;-import org.apache.solr.common.params.SolrParams;-import org.apache.solr.schema.SimilarityFactory;--/**- * Factory for {@link LegacyBM25Similarity}.- * Use this to force explicit creation of the BM25 formula that was used by BM25Similarity before Solr/Lucene 8.0.0.- * Note that {@link SchemaSimilarityFactory} will automatically create an instance of LegacyBM25Similarity if luceneMatchVersion is < 8.0.0- * <p>- * Parameters:- * <ul>- * <li>k1 (float): Controls non-linear term frequency normalization (saturation).- * The default is <code>1.2</code>- * <li>b (float): Controls to what degree document length normalizes tf values.- * The default is <code>0.75</code>- * <li>discountOverlaps (bool): True if overlap tokens (tokens with a position of increment of zero) are- * discounted from the document's length.- * The default is <code>true</code>- * </ul>- * @lucene.experimental- * @since 8.0.0- *- * @deprecated {@link BM25SimilarityFactory} should be used instead- */-@Deprecated-public class LegacyBM25SimilarityFactory extends SimilarityFactory {- private LegacyBM25Similarity similarity;-- @Override- public void init(SolrParams params) {- super.init(params);- boolean discountOverlaps = params.getBool("discountOverlaps", true);- float k1 = params.getFloat("k1", 1.2f);- float b = params.getFloat("b", 0.75f);- similarity = new LegacyBM25Similarity(k1, b, discountOverlaps);- }-- @Override- public Similarity getSimilarity() {- return similarity;- }-}diff --git a/solr/core/src/java/org/apache/solr/search/similarities/SchemaSimilarityFactory.java b/solr/core/src/java/org/apache/solr/search/similarities/SchemaSimilarityFactory.javaindex 0b174a6ecc0..d08e918ed35 100644--- a/solr/core/src/java/org/apache/solr/search/similarities/SchemaSimilarityFactory.java+++ b/solr/core/src/java/org/apache/solr/search/similarities/SchemaSimilarityFactory.java@@ -19,8 +19,6 @@ package org.apache.solr.search.similarities;import org.apache.lucene.search.similarities.BM25Similarity;import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;import org.apache.lucene.search.similarities.Similarity;-import org.apache.lucene.misc.search.similarity.LegacyBM25Similarity;-import org.apache.lucene.util.Version;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrException.ErrorCode;import org.apache.solr.common.params.SolrParams;@@ -35,13 +33,7 @@ import org.apache.solr.util.plugin.SolrCoreAware;* that delegates to the field type, if it's configured. For field types that* do not have a <code>Similarity</code> explicitly configured, the global <code>Similarity</code>* will use per fieldtype defaults -- either based on an explicitly configured- * <code>defaultSimFromFieldType</code> a sensible default depending on the {@link Version}- * matching configured:- * </p>- * <ul>- * <li><code>luceneMatchVersion < 8.0</code> = {@link LegacyBM25Similarity}</li>- * <li><code>luceneMatchVersion >= 8.0</code> = {@link BM25Similarity}</li>- * </ul>+ * <code>defaultSimFromFieldType</code> or {@link BM25Similarity} as a sensible default.* <p>* The <code>defaultSimFromFieldType</code> option accepts the name of any fieldtype, and uses* whatever <code>Similarity</code> is explicitly configured for that fieldType as the default for@@ -85,12 +77,10 @@ public class SchemaSimilarityFactory extends SimilarityFactory implements SolrCoprivate volatile SolrCore core; // set by inform(SolrCore)private volatile Similarity similarity; // lazy instantiated- private Version coreVersion = Version.LATEST;@Overridepublic void inform(SolrCore core) {this.core = core;- this.coreVersion = this.core.getSolrConfig().luceneMatchVersion;}@Override@@ -111,9 +101,7 @@ public class SchemaSimilarityFactory extends SimilarityFactory implements SolrCoSimilarity defaultSim = null;if (null == defaultSimFromFieldType) {// nothing configured, choose a sensible implicit default...- defaultSim = coreVersion.onOrAfter(Version.LUCENE_8_0_0) ?- new BM25Similarity() :- new LegacyBM25Similarity();+ defaultSim = new BM25Similarity();} else {FieldType defSimFT = core.getLatestSchema().getFieldTypeByName(defaultSimFromFieldType);if (null == defSimFT) {diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-bm25.xml b/solr/core/src/test-files/solr/collection1/conf/schema-bm25.xmlindex 549efd6b187..02a0d08b36b 100644--- a/solr/core/src/test-files/solr/collection1/conf/schema-bm25.xml+++ b/solr/core/src/test-files/solr/collection1/conf/schema-bm25.xml@@ -36,27 +36,9 @@</similarity></fieldType>- <!-- legacybm25 with default parameters -->- <fieldType name="legacy_text" class="solr.TextField">- <analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>- <similarity class="solr.LegacyBM25SimilarityFactory"/>- </fieldType>-- <!-- legacybm25 with parameters -->- <fieldType name="legacy_text_params" class="solr.TextField">- <analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>- <similarity class="solr.LegacyBM25SimilarityFactory">- <float name="k1">1.2</float>- <float name="b">0.76</float>- </similarity>- </fieldType>--<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/><field name="text" type="text" indexed="true" stored="false"/><field name="text_params" type="text_params" indexed="true" stored="false"/>- <field name="legacy_text" type="legacy_text" indexed="true" stored="false"/>- <field name="legacy_text_params" type="legacy_text_params" indexed="true" stored="false"/><uniqueKey>id</uniqueKey>diff --git a/solr/core/src/test/org/apache/solr/search/similarities/TestLegacyBM25SimilarityFactory.java b/solr/core/src/test/org/apache/solr/search/similarities/TestLegacyBM25SimilarityFactory.javadeleted file mode 100644index e13e1530742..00000000000--- a/solr/core/src/test/org/apache/solr/search/similarities/TestLegacyBM25SimilarityFactory.java+++ /dev/null@@ -1,45 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You 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- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * 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.- */-package org.apache.solr.search.similarities;--import org.apache.lucene.search.similarities.Similarity;-import org.apache.lucene.misc.search.similarity.LegacyBM25Similarity;-import org.junit.BeforeClass;--/**- * Tests {@link LegacyBM25SimilarityFactory}- */-public class TestLegacyBM25SimilarityFactory extends BaseSimilarityTestCase {- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-basic.xml","schema-bm25.xml");- }-- /** bm25 with default parameters */- public void test() throws Exception {- assertEquals(LegacyBM25Similarity.class, getSimilarity("legacy_text").getClass());- }-- /** bm25 with parameters */- public void testParameters() throws Exception {- Similarity sim = getSimilarity("legacy_text_params");- assertEquals(LegacyBM25Similarity.class, sim.getClass());- LegacyBM25Similarity bm25 = (LegacyBM25Similarity) sim;- assertEquals(1.2f, bm25.getK1(), 0.01f);- assertEquals(0.76f, bm25.getB(), 0.01f);- }-}diff --git a/solr/solr-ref-guide/src/major-changes-in-solr-9.adoc b/solr/solr-ref-guide/src/major-changes-in-solr-9.adocindex c2e6933513c..43190949b70 100644--- a/solr/solr-ref-guide/src/major-changes-in-solr-9.adoc+++ b/solr/solr-ref-guide/src/major-changes-in-solr-9.adoc@@ -227,6 +227,8 @@ What percentage of them get reported to a tracing server is up to you.=== Schema Changes in 9+* `LegacyBM25SimilarityFactory` has been removed.+=== Authentication & Security Changes in Solr 9* BasicAuthPlugin property 'blockUnknown' now defaults to 'true'. This change is backward incompatible. If you need the pre-9.0 default behavior, you need to explicitly set 'blockUnknown':'false' in security.json.diff --git a/solr/solr-ref-guide/src/schema-elements.adoc b/solr/solr-ref-guide/src/schema-elements.adocindex cf99c57e5e0..6e19834cc41 100644--- a/solr/solr-ref-guide/src/schema-elements.adoc+++ b/solr/solr-ref-guide/src/schema-elements.adoc@@ -152,7 +152,7 @@ One key exception to this is that you may explicitly declare a {solr-javadocs}/cIn the example above `IBSimilarityFactory` (using the Information-Based model) will be used for any fields of type `text_ib`, while `DFRSimilarityFactory` (divergence from random) will be used for any fields of type `text_dfr`, as well as any fields using a type that does not explicitly specify a `<similarity/>`.-If `SchemaSimilarityFactory` is explicitly declared without configuring a `defaultSimFromFieldType`, then `BM25Similarity` is implicitly used as the default for `luceneMatchVersion >= 8.0.0` and otherwise the deprecated `LegacyBM25Similarity` (which will be removed in 9.x) is used to mimic the same BM25 formula that was the default in those versions.+If `SchemaSimilarityFactory` is explicitly declared without configuring a `defaultSimFromFieldType`, then `BM25Similarity` is implicitly used as the default.In addition to the various factories mentioned on this page, there are several other similarity implementations that can be used such as the `SweetSpotSimilarityFactory`, `ClassicSimilarityFactory` etc.For details, see the Solr Javadocs for the {solr-javadocs}/core/org/apache/solr/schema/SimilarityFactory.html[similarity factories].