Skip to content

Apache Lucene open-source search software

Merged revision(s) 1672531 from lucene/dev/branches/branch_5x: SOLR-7373: let AbstractSpatialFieldType set the context ........

Ryan McKinleya2d29b8e1275
diff --git a/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java b/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
index 89357eb9adb..be641f7bc3a 100644
--- a/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
+++ b/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
@@ -113,11 +113,13 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extend
protected void init(IndexSchema schema, Map<String, String> args) {
super.init(schema, args);
- //Solr expects us to remove the parameters we've used.
- MapListener<String, String> argsWrap = new MapListener<>(args);
- ctx = SpatialContextFactory.makeSpatialContext(argsWrap, schema.getResourceLoader().getClassLoader());
- args.keySet().removeAll(argsWrap.getSeenKeys());
-
+ if(ctx==null) { // subclass can set this directly
+ //Solr expects us to remove the parameters we've used.
+ MapListener<String, String> argsWrap = new MapListener<>(args);
+ ctx = SpatialContextFactory.makeSpatialContext(argsWrap, schema.getResourceLoader().getClassLoader());
+ args.keySet().removeAll(argsWrap.getSeenKeys());
+ }
+
final String unitsErrMsg = "units parameter is deprecated, please use distanceUnits instead for field types with class " +
getClass().getSimpleName();
this.units = args.remove("units");//deprecated