I'm just starting with Solr. I'm using Solr 3.1.0, and I want to use EmbeddedSolrServer with a multicore setup, even though I currently have only one core (various documents I read suggest starting that way even if you have one core, to get the better administrative tools supported by mutlicore).
I have two questions: 1. Does the first code sample below start the server with multicore or not? 2. Why is it the first sample work and the second does not? My solr.xml looks like this: <solr persistent="true"> <cores adminPath="/admin/cores" defaultCoreName="mycore" sharedLib="lib"> <core name="mycore" instanceDir="mycore" /> </cores> </solr> It's in a directory called solrhome in war/WEB-INF. I can get the server to come up cleanly if I follow an example in the Packt Solr book (p. 231), but I'm not sure if this enables multi-core or not: File solrXML = new File("war/WEB-INF/solrhome/solr.xml"); String solrHome = solrXML.getParentFile().getAbsolutePath(); String dataDir = solrHome + "/data"; coreContainer = new CoreContainer(solrHome); SolrConfig solrConfig = new SolrConfig(solrHome, "solrconfig.xml", null); CoreDescriptor coreDescriptor = new CoreDescriptor(coreContainer, "mycore", solrHome); SolrCore solrCore = new SolrCore("mycore", dataDir + "/" + "mycore", solrConfig, null, coreDescriptor); coreContainer.register(solrCore, false); embeddedSolr = new EmbeddedSolrServer(coreContainer, "mycore"); The documentation on the Solr wiki says I should configure the EmbeddedSolrServer for multicore like this: File home = new File( "/path/to/solr/home" ); File f = new File( home, "solr.xml" ); CoreContainer container = new CoreContainer(); container.load( "/path/to/solr/home", f ); EmbeddedSolrServer server = new EmbeddedSolrServer( container, "core name as defined in solr.xml" ); When I try to do this, I get an error saying that it cannot find solrconfig.xml: File solrXML = new File("war/WEB-INF/solrhome/solr.xml"); String solrHome = solrXML.getParentFile().getAbsolutePath(); coreContainer = new CoreContainer(); coreContainer.load(solrHome, solrXML); embeddedSolr = new EmbeddedSolrServer(coreContainer, "mycore"); The message says it is looking in an odd place (I removed my user name from this). Why is it looking in solrhome/mycore/conf for solrconfig.xml? Both that and my schema.xml are in solrhome/conf. How can I point it at the right place? I tried adding "<REMOVED>\workspace-Solr\institution-webapp\war\WEB-INF\solrhome\conf" to the classpath, but got the same result: SEVERE: java.lang.RuntimeException: Can't find resource 'solrconfig.xml' in classpath or '<REMOVED>\workspace-Solr\institution-webapp\war\WEB-INF\solrhome\mycore\conf/', cwd=<REMOVED>\workspace-Solr\institution-webapp at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:268) at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:234) at org.apache.solr.core.Config.<init>(Config.java:141) at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:132) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:430) at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316) at org.apache.solr.core.CoreContainer.load(CoreContainer.java:207)