diff --git a/CHANGES.txt b/CHANGES.txt index 301fa6ff76c..f687f9db7c0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -70,7 +70,7 @@ New Features * SOLR-1177: Distributed Search support for TermsComponent (Matt Weber via shalin) -* SOLR-1621: Allow current single core deployments to be specified by solr.xml (Mark Miller , noble) +* SOLR-1621, SOLR-1722: Allow current single core deployments to be specified by solr.xml (Mark Miller , noble) * SOLR-1532: Allow StreamingUpdateSolrServer to use a provided HttpClient (Gabriele Renzi via shalin) diff --git a/example/solr/solr.xml b/example/solr/solr.xml index c231c9d02ad..6f0d0fd3cda 100644 --- a/example/solr/solr.xml +++ b/example/solr/solr.xml @@ -28,7 +28,7 @@ adminPath: RequestHandler path to manage cores. If 'null' (or absent), cores will not be manageable via request handler --> - - + + diff --git a/src/java/org/apache/solr/core/CoreContainer.java b/src/java/org/apache/solr/core/CoreContainer.java index d860567c8bb..2a1435c9b31 100644 --- a/src/java/org/apache/solr/core/CoreContainer.java +++ b/src/java/org/apache/solr/core/CoreContainer.java @@ -50,7 +50,7 @@ import org.xml.sax.SAXException; */ public class CoreContainer { - private static final String DEFAULT_CORE_NAME = "DEFAULT_CORE"; + private static final String DEFAULT_DEFAULT_CORE_NAME = "collection1"; protected static Logger log = LoggerFactory.getLogger(CoreContainer.class); @@ -70,6 +70,8 @@ public class CoreContainer protected String solrHome; protected String solrConfigFilenameOverride; + private String defaultCoreName = DEFAULT_DEFAULT_CORE_NAME; + public CoreContainer() { solrHome = SolrResourceLoader.locateSolrHome(); } @@ -210,7 +212,10 @@ public class CoreContainer solrHome = loader.getInstanceDir(); try { Config cfg = new Config(loader, null, cfgis, null); - + String dcoreName = cfg.get("solr/@defaultCoreName", null); + if(dcoreName != null) { + defaultCoreName = dcoreName; + } persistent = cfg.getBool( "solr/@persistent", false ); libDir = cfg.get( "solr/@sharedLib", null); adminPath = cfg.get( "solr/cores/@adminPath", null ); @@ -248,7 +253,7 @@ public class CoreContainer Node node = nodes.item(i); try { String name = DOMUtil.getAttr(node, "name", null); - if(name.equals(DEFAULT_CORE_NAME)){ + if(name.equals(defaultCoreName)){ if(defaultCoreFound) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Only one 'DEFAULT_CORE' is allowed "); defaultCoreFound = true; name=""; @@ -488,7 +493,7 @@ public class CoreContainer } private String checkDefault(String name) { - return name.length() == 0 || DEFAULT_CORE_NAME.equals(name) || name.trim().length() == 0 ? "" : name; + return name.length() == 0 || defaultCoreName.equals(name) || name.trim().length() == 0 ? "" : name; } /** @@ -769,7 +774,7 @@ public class CoreContainer private static final String DEF_SOLR_XML ="\n" + "\n" + " \n" + - " \n" + + " \n" + " \n" + ""; }