diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 0669e7768e4..0428c8819dc 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -140,6 +140,12 @@ Jetty 9.2.13.v20150730 Upgrading from Solr 5.3 ----------------------- +* DefaultSimilarityFactory has been renamed to ClassicSimilarityFactory to mach the underlying rename of + DefaultSimilarity to ClassicSimilarity and the (eventual) move away from using it as a default. + If you currently have DefaultSimilarityFactory explicitly refrenced in your schema.xml, you will now get + a warning urging you to edit your config to use the functionally identical ClassicSimilarityFactory. + DefaultSimilarityFactory will be removed completely in Solr 6. See SOLR-8239 for more details. + * SOLR-7859: The following APIs are now deprecated: - SolrCore.getStartTime: Use SolrCore.getStartTimeStamp instead. - SolrIndexSearcher.getOpenTime: Use SolrIndexSearcher.getOpenTimeStamp instead. @@ -443,6 +449,8 @@ Other Changes * SOLR-8147: contrib/analytics FieldFacetAccumulator now throws IOException instead of SolrException (Scott Stults via Christine Poerschke) +* SOLR-8239: Added ClassicSimilarityFactory, marked DefaultSimilarityFactory as deprecated. (hossman) + ================== 5.3.1 ================== Bug Fixes diff --git a/solr/contrib/clustering/src/test-files/clustering/solr/collection1/conf/schema.xml b/solr/contrib/clustering/src/test-files/clustering/solr/collection1/conf/schema.xml index 1fdf3b56275..39b6b168768 100644 --- a/solr/contrib/clustering/src/test-files/clustering/solr/collection1/conf/schema.xml +++ b/solr/contrib/clustering/src/test-files/clustering/solr/collection1/conf/schema.xml @@ -332,19 +332,4 @@ - - - - - - diff --git a/solr/contrib/uima/src/test-files/uima/solr/collection1/conf/schema.xml b/solr/contrib/uima/src/test-files/uima/solr/collection1/conf/schema.xml index 6bf2a54526a..483fa2aea8b 100644 --- a/solr/contrib/uima/src/test-files/uima/solr/collection1/conf/schema.xml +++ b/solr/contrib/uima/src/test-files/uima/solr/collection1/conf/schema.xml @@ -607,23 +607,4 @@ --> - - - - - - - diff --git a/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml b/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml index dfba444f80e..2ab88082353 100644 --- a/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml +++ b/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml @@ -611,22 +611,4 @@ - - - - - - diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java index 5fecdbe5b5a..966c295fa43 100644 --- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java +++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java @@ -65,7 +65,7 @@ import org.apache.solr.core.SolrResourceLoader; import org.apache.solr.request.LocalSolrQueryRequest; import org.apache.solr.response.SchemaXmlWriter; import org.apache.solr.response.SolrQueryResponse; -import org.apache.solr.search.similarities.DefaultSimilarityFactory; +import org.apache.solr.search.similarities.ClassicSimilarityFactory; import org.apache.solr.util.DOMUtil; import org.apache.solr.util.plugin.SolrCoreAware; import org.slf4j.Logger; @@ -497,7 +497,7 @@ public class IndexSchema { Node node = (Node) xpath.evaluate(expression, document, XPathConstants.NODE); similarityFactory = readSimilarity(loader, node); if (similarityFactory == null) { - similarityFactory = new DefaultSimilarityFactory(); + similarityFactory = new ClassicSimilarityFactory(); final NamedList similarityParams = new NamedList(); Version luceneVersion = getDefaultLuceneMatchVersion(); similarityFactory.init(SolrParams.toSolrParams(similarityParams)); diff --git a/solr/core/src/java/org/apache/solr/search/similarities/ClassicSimilarityFactory.java b/solr/core/src/java/org/apache/solr/search/similarities/ClassicSimilarityFactory.java new file mode 100644 index 00000000000..a8cf6abea43 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/search/similarities/ClassicSimilarityFactory.java @@ -0,0 +1,65 @@ +package org.apache.solr.search.similarities; + +/* + * 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. + */ + +import org.apache.lucene.search.similarities.ClassicSimilarity; +import org.apache.lucene.search.similarities.Similarity; +import org.apache.lucene.search.similarities.TFIDFSimilarity; // javadoc +import org.apache.solr.common.params.SolrParams; +import org.apache.solr.schema.SimilarityFactory; + +/** + * Factory for {@link ClassicSimilarity} + *

+ * ClassicSimilarity is Lucene's original scoring implementation, based + * upon the Vector Space Model. + *

+ * Optional settings: + *

+ * @see TFIDFSimilarity + * @lucene.experimental + */ +public class ClassicSimilarityFactory extends SimilarityFactory { + + /** Init param name for specifying the value to use in + * {@link ClassicSimilarity#setDiscountOverlaps(boolean)} + */ + public static final String DISCOUNT_OVERLAPS = "discountOverlaps"; + + /** + * Controls the value of {@link ClassicSimilarity#setDiscountOverlaps(boolean)} + * on newly constructed instances of {@link ClassicSimilarity} + */ + protected boolean discountOverlaps = true; + + @Override + public void init(SolrParams params) { + super.init(params); + discountOverlaps = params.getBool(DISCOUNT_OVERLAPS, true); + } + + @Override + public Similarity getSimilarity() { + ClassicSimilarity sim = new ClassicSimilarity(); + sim.setDiscountOverlaps(discountOverlaps); + return sim; + } +} diff --git a/solr/core/src/java/org/apache/solr/search/similarities/DefaultSimilarityFactory.java b/solr/core/src/java/org/apache/solr/search/similarities/DefaultSimilarityFactory.java index 4b3cc38ac0b..e3b18f5c902 100644 --- a/solr/core/src/java/org/apache/solr/search/similarities/DefaultSimilarityFactory.java +++ b/solr/core/src/java/org/apache/solr/search/similarities/DefaultSimilarityFactory.java @@ -16,50 +16,29 @@ package org.apache.solr.search.similarities; * See the License for the specific language governing permissions and * limitations under the License. */ - -import org.apache.lucene.search.similarities.ClassicSimilarity; import org.apache.lucene.search.similarities.Similarity; -import org.apache.lucene.search.similarities.TFIDFSimilarity; // javadoc + import org.apache.solr.common.params.SolrParams; -import org.apache.solr.schema.SimilarityFactory; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** - * Factory for {@link ClassicSimilarity} - *

- * ClassicSimilarity is Lucene's original scoring implementation, based - * upon the Vector Space Model. - *

- * Optional settings: - *

- * @see TFIDFSimilarity - * @lucene.experimental + * @deprecated This class has been renamed to ClassicSimilarityFactory to reflect the renaming of the underlying Similarity returned. + * + * @see ClassicSimilarityFactory */ -public class DefaultSimilarityFactory extends SimilarityFactory { - - /** Init param name for specifying the value to use in - * {@link ClassicSimilarity#setDiscountOverlaps(boolean)} - */ - public static final String DISCOUNT_OVERLAPS = "discountOverlaps"; - - /** - * Controls the value of {@link ClassicSimilarity#setDiscountOverlaps(boolean)} - * on newly constructed instances of {@link ClassicSimilarity} - */ - protected boolean discountOverlaps = true; +@Deprecated +public class DefaultSimilarityFactory extends ClassicSimilarityFactory { + + public static final Logger log = LoggerFactory.getLogger(DefaultSimilarityFactory.class); @Override public void init(SolrParams params) { super.init(params); - discountOverlaps = params.getBool(DISCOUNT_OVERLAPS, true); - } - - @Override - public Similarity getSimilarity() { - ClassicSimilarity sim = new ClassicSimilarity(); - sim.setDiscountOverlaps(discountOverlaps); - return sim; + log.warn("DefaultSimilarityFactory has been renamed and deprecated. " + + "Please update your configuration file to refer to ClassicSimilarityFactory instead"); } + } 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 2e377a1605c..390a964e404 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 @@ -35,9 +35,9 @@ import org.apache.solr.util.plugin.SolrCoreAware; * NOTE: Users should be aware that in addition to supporting * Similarity configurations specified on individual * field types, this factory also differs in behavior from - * {@link DefaultSimilarityFactory} because of other differences in the + * {@link ClassicSimilarityFactory} because of other differences in the * implementations of PerFieldSimilarityWrapper and - * DefaultSimilarity - notably in methods such as + * {@link ClassicSimilarity} - notably in methods such as * {@link Similarity#coord} and {@link Similarity#queryNorm}. *

* diff --git a/solr/core/src/java/org/apache/solr/search/similarities/SweetSpotSimilarityFactory.java b/solr/core/src/java/org/apache/solr/search/similarities/SweetSpotSimilarityFactory.java index 42ac4e96413..ac4976d4483 100644 --- a/solr/core/src/java/org/apache/solr/search/similarities/SweetSpotSimilarityFactory.java +++ b/solr/core/src/java/org/apache/solr/search/similarities/SweetSpotSimilarityFactory.java @@ -34,7 +34,7 @@ import static org.apache.solr.common.SolrException.ErrorCode.*; *

*

* In addition to the discountOverlaps init param supported by - * {@link DefaultSimilarityFactory} The following sets of init params are + * {@link ClassicSimilarityFactory} The following sets of init params are * supported by this factory: *

*