Even if I set CORE_CONFIGSET I get org.apache.solr.common.SolrException: Unable to create core [test] at org.apache.solr.core.CoreContainer.create(CoreContainer.java:507) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:466) at ch.mysign.indexing.solr.SolrTest.createANewCore(SolrTest.java:123) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:483) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:483) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: org.apache.solr.common.SolrException: Could not load conf for core test: Error loading solr config from C:/tmp/solr/cores/test\conf\solrconfig.xml at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:66) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:489) ... 12 more Caused by: org.apache.solr.common.SolrException: Error loading solr config from C:/tmp/solr/cores/test\conf\solrconfig.xml at org.apache.solr.core.SolrConfig.readFromResourceLoader(SolrConfig.java:154) at org.apache.solr.core.ConfigSetService.createSolrConfig(ConfigSetService.java:80) at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:61) ... 13 more Caused by: java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or 'C:\tmp\solr\cores\test\conf' at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:362) at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:308) at org.apache.solr.core.Config.<init>(Config.java:117) at org.apache.solr.core.Config.<init>(Config.java:87) at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:167) at org.apache.solr.core.SolrConfig.readFromResourceLoader(SolrConfig.java:145) ... 15 more
My unittest looks alike: String pathToSolr = "C:/tmp/solr/"; String pathToSolrCores = pathToSolr + "cores"; File solrCoresDir = new File( pathToSolrCores ); if ( solrCoresDir.exists() ) { FileUtil.deleteDirectory( solrCoresDir ); } FileUtil.createDirectories( pathToSolrCores ); CoreContainer container = CoreContainer.createAndLoad( pathToSolrCores, new File( pathToSolr + "solr.xml" ) ); // String coreRootDirectory = container.getCoreRootDirectory(); Collection<String> coreNames = container.getAllCoreNames(); Assert.assertTrue( coreNames.isEmpty() ); CoreDescriptor cd = new CoreDescriptor( container, "test", pathToSolrCores + "/test" ); cd.getSubstitutableProperties().setProperty( cd.CORE_CONFIGSET, "configset" ); // I also tried cd.getSubstitutableProperties().setProperty( cd.CORE_CONFIGSET, pathToSolr + "configsets/configset" ); // SolrCore core = container.create( cd ); coreNames = container.getAllCoreNames(); Assert.assertFalse( coreNames.isEmpty() ); The structure of /tmp/solr looks like this: C:\TMP\SOLR ├───configsets │ └───configset │ └───conf | └───schema.xml | └───solrconfig.xml └───cores └───solr.xml solr.xml: <solr> <shareSchema>true</shareSchema> <configSetBaseDir>c:/tmp/solr/configsets</configSetBaseDir> <solrcloud> ... </solrcloud> <shardHandlerFactory name="shardHandlerFactory" ... </shardHandlerFactory> </solr> -----Ursprüngliche Nachricht----- Von: Alexandre Rafalovitch [mailto:arafa...@gmail.com] Gesendet: Montag, 24. November 2014 16:49 An: solr-user Betreff: Re: CoreContainer : create new cores reusing/sharing solrconfig.xml and schema.xml I haven't done this myself, but it is defined as a constant in the CoreDescriptor: http://www.solr-start.com/javadoc/solr-lucene/org/apache/solr/core/CoreDescriptor.html#CORE_CONFIGSET You could also look at the tests and see whether it is used. Regards, Alex. Personal: http://www.outerthoughts.com/ and @arafalov Solr resources and newsletter: http://www.solr-start.com/ and @solrstart Solr popularizers community: https://www.linkedin.com/groups?gid=6713853 On 24 November 2014 at 10:43, Clemens Wyss DEV <clemens...@mysign.ch> wrote: > Thanks fort he quick reply. > But how do I hand in the configSet to use. I guess through the CoreDescriptor? > > -----Ursprüngliche Nachricht----- > Von: Alexandre Rafalovitch [mailto:arafa...@gmail.com] > Gesendet: Montag, 24. November 2014 16:27 > An: solr-user > Betreff: Re: CoreContainer : create new cores reusing/sharing > solrconfig.xml and schema.xml > > Have you tried Configsets: > https://cwiki.apache.org/confluence/display/solr/Config+Sets ? > > Regards, > Alex. > Personal: http://www.outerthoughts.com/ and @arafalov Solr resources > and newsletter: http://www.solr-start.com/ and @solrstart Solr > popularizers community: https://www.linkedin.com/groups?gid=6713853 > > > On 24 November 2014 at 10:14, Clemens Wyss DEV <clemens...@mysign.ch> wrote: >> Given the following directory/file structure >> >> .../solrhome >> .../solrhome/solr.xml >> .../solrhome/config/ >> .../solrhome/config/schema.xml >> .../solrhome/config/solrconfig.xml >> .../solrhome/cores >> >> How can I programmatically (CoreContainer) create a new core below >> .../solrhome/cores that makes use of solrconfig.xml and schema.xml? >> The new core should use the config files in .../solrhome/config/ >> >> Thx >> Clemens