mirror of
https://github.com/apache/lucene.git
synced 2025-02-21 17:46:28 +00:00
SOLR-4623: When serializing similarity factories, don't reduce class names of Similarity's wrapped with the anonymous factory to 'solr.<SimpleClassName>'; also, only reduce the class name of sim factories located in the org.apache.solr.search.similarities package, rather than that of any sim factory under packages org.apache.lucene.** and org.apache.solr.**
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1461378 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fda68e7322
commit
77e9e58300
@ -42,6 +42,7 @@ import java.util.Iterator;
|
|||||||
*/
|
*/
|
||||||
public abstract class SimilarityFactory {
|
public abstract class SimilarityFactory {
|
||||||
public static final String CLASS_NAME = "class";
|
public static final String CLASS_NAME = "class";
|
||||||
|
private static final String SOLR_SIMILARITIES_PACKAGE = "org.apache.solr.search.similarities";
|
||||||
|
|
||||||
protected SolrParams params;
|
protected SolrParams params;
|
||||||
|
|
||||||
@ -51,14 +52,14 @@ public abstract class SimilarityFactory {
|
|||||||
public abstract Similarity getSimilarity();
|
public abstract Similarity getSimilarity();
|
||||||
|
|
||||||
|
|
||||||
private static String normalizeSPIname(String fullyQualifiedName) {
|
private static String normalizeName(String fullyQualifiedName) {
|
||||||
if (fullyQualifiedName.startsWith("org.apache.lucene.") || fullyQualifiedName.startsWith("org.apache.solr.")) {
|
if (fullyQualifiedName.startsWith(SOLR_SIMILARITIES_PACKAGE + ".")) {
|
||||||
return "solr" + fullyQualifiedName.substring(fullyQualifiedName.lastIndexOf('.'));
|
return "solr" + fullyQualifiedName.substring(SOLR_SIMILARITIES_PACKAGE.length());
|
||||||
}
|
}
|
||||||
return fullyQualifiedName;
|
return fullyQualifiedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a description of this field's similarity, if any */
|
/** Returns a serializable description of this similarity(factory) */
|
||||||
public SimpleOrderedMap<Object> getNamedPropertyValues() {
|
public SimpleOrderedMap<Object> getNamedPropertyValues() {
|
||||||
String className = getClass().getName();
|
String className = getClass().getName();
|
||||||
if (className.startsWith("org.apache.solr.schema.IndexSchema$")) {
|
if (className.startsWith("org.apache.solr.schema.IndexSchema$")) {
|
||||||
@ -66,10 +67,10 @@ public abstract class SimilarityFactory {
|
|||||||
className = getSimilarity().getClass().getName();
|
className = getSimilarity().getClass().getName();
|
||||||
} else {
|
} else {
|
||||||
// Only normalize factory names
|
// Only normalize factory names
|
||||||
className = normalizeSPIname(className);
|
className = normalizeName(className);
|
||||||
}
|
}
|
||||||
SimpleOrderedMap<Object> props = new SimpleOrderedMap<Object>();
|
SimpleOrderedMap<Object> props = new SimpleOrderedMap<Object>();
|
||||||
props.add(CLASS_NAME, normalizeSPIname(className));
|
props.add(CLASS_NAME, className);
|
||||||
if (null != params) {
|
if (null != params) {
|
||||||
Iterator<String> iter = params.getParameterNamesIterator();
|
Iterator<String> iter = params.getParameterNamesIterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user