This is an automated email from the ASF dual-hosted git repository.
cpoerschke pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 3a5e8ce SOLR-13138: remove deprecated LegacyBM25SimilarityFactory
(#274)
3a5e8ce is described below
commit 3a5e8ce35082cb6c5fc949878f7a3422cbe9d009
Author: Christine Poerschke <[email protected]>
AuthorDate: Wed Sep 29 09:39:37 2021 +0100
SOLR-13138: remove deprecated LegacyBM25SimilarityFactory (#274)
---
solr/CHANGES.txt | 2 +
.../search/similarities/BM25SimilarityFactory.java | 3 --
.../similarities/LegacyBM25SimilarityFactory.java | 61 ----------------------
.../similarities/SchemaSimilarityFactory.java | 16 +-----
.../solr/collection1/conf/schema-bm25.xml | 18 -------
.../TestLegacyBM25SimilarityFactory.java | 45 ----------------
.../src/major-changes-in-solr-9.adoc | 2 +
solr/solr-ref-guide/src/schema-elements.adoc | 2 +-
8 files changed, 7 insertions(+), 142 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 2d1e1b4..744c63b 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 execution
diff --git
a/solr/core/src/java/org/apache/solr/search/similarities/BM25SimilarityFactory.java
b/solr/core/src/java/org/apache/solr/search/similarities/BM25SimilarityFactory.java
index 944be03..2a01d28 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.java
deleted file mode 100644
index e426087..0000000
---
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.java
index 0b174a6..d08e918 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 SolrCo
private volatile SolrCore core; // set by inform(SolrCore)
private volatile Similarity similarity; // lazy instantiated
- private Version coreVersion = Version.LATEST;
@Override
public void inform(SolrCore core) {
this.core = core;
- this.coreVersion = this.core.getSolrConfig().luceneMatchVersion;
}
@Override
@@ -111,9 +101,7 @@ public class SchemaSimilarityFactory extends
SimilarityFactory implements SolrCo
Similarity 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.xml
index 549efd6..02a0d08 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.java
deleted file mode 100644
index e13e153..0000000
---
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.adoc
index c2e6933..4319094 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.adoc
index cf99c57..6e19834 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}/c
In 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].