RE: EmbeddedSolrServer No such core: collection1

2015-07-08 Thread Chaushu, Shani
Hi,
My problem was that I didn't had core.properties file, so it couldn't create 
the core.

Thanks for the help 
Shani

-Original Message-
From: Upayavira [mailto:u...@odoko.co.uk] 
Sent: Sunday, July 05, 2015 18:25
To: solr-user@lucene.apache.org
Subject: Re: EmbeddedSolrServer No such core: collection1

Hi Shani,

What version of Solr are you using? The instructions you quote look like they 
are for something like <4.4 from what you have written below.

The below is cloned from one of my projects, and hacked without testing, but I 
hope it gives you the idea of how it can be done.

  public SolrServer getEmbeddedServer(String solrHome, String
  solrConfigurationPath, String myCore) {
// Create solr_home directory with solr.xml
new File(solrHome).mkdirs();
FileUtils.copyFile(new File(config.getSolrXmlPath()), new
File(solrHome, "solr.xml"));

// Create config dir for my new core
File myCoreConfig = new File(solrHome + "/" + myCore + "/conf");
myCoreConfig.mkdirs();
FileUtils.copyDirectory(new File(solrConfigurationPath),
myCoreConfig);

// Create core.properties file
FileUtils.write(new File(core, "core.properties"), "name=" +
coreName);

   // Create CoreContainer and EmbeddedSolrServer
File solrXml = new File(solrHome, "solr.xml");
CoreContainer coreContainer = CoreContainer.createAndLoad(solrHome,
solrXml);
EmbeddedSolrServer newServer = new EmbeddedSolrServer(coreContainer,
myCore);
  }


Upayavira

On Sun, Jul 5, 2015, at 01:17 PM, Chaushu, Shani wrote:
> Hi,
> I'm using EmbeddedSolrServer   for testing the solr.
> I went step by step in this instuctions (for solr 4) 
> https://wiki.searchtechnologies.com/index.php/Unit_Testing_with_Embedd
> ed_Solr I can see that the config loaded, but when I try to put 
> document, the error I get is:
> org.apache.solr.common.SolrException: No such core: collection1
> 
> I'm sure it's something in the solr.xml, but I couldn't find the 
> issue, Any thought?
> 
> in the solr.xml I have:
> 
> 
> 
> ${host:}
> ${jetty.port:8983}
> ${hostContext:solr}
> ${zkClientTimeout:3}
>  name="genericCoreNodeNames">${genericCoreNodeNames:true}
> 
> 
> 
> 
> 
> 
> 
> 
> 
>   class="HttpShardHandlerFactory">
> ${socketTimeout:0}
> ${connTimeout:0}
> 
> 
> 
> 
> Thanks,
> Shani
> 
> 
> -
> Intel Electronics Ltd.
> 
> This e-mail and any attachments may contain confidential material for 
> the sole use of the intended recipient(s). Any review or distribution 
> by others is strictly prohibited. If you are not the intended 
> recipient, please contact the sender and delete all copies.
-
Intel Electronics Ltd.

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



Re: EmbeddedSolrServer No such core: collection1

2015-07-05 Thread Upayavira
Hi Shani,

What version of Solr are you using? The instructions you quote look like
they are for something like <4.4 from what you have written below.

The below is cloned from one of my projects, and hacked without testing,
but I hope it gives you the idea of how it can be done.

  public SolrServer getEmbeddedServer(String solrHome, String
  solrConfigurationPath, String myCore) {
// Create solr_home directory with solr.xml
new File(solrHome).mkdirs();
FileUtils.copyFile(new File(config.getSolrXmlPath()), new
File(solrHome, "solr.xml"));

// Create config dir for my new core
File myCoreConfig = new File(solrHome + "/" + myCore + "/conf");
myCoreConfig.mkdirs();
FileUtils.copyDirectory(new File(solrConfigurationPath),
myCoreConfig);

// Create core.properties file
FileUtils.write(new File(core, "core.properties"), "name=" +
coreName);

   // Create CoreContainer and EmbeddedSolrServer
File solrXml = new File(solrHome, "solr.xml");
CoreContainer coreContainer = CoreContainer.createAndLoad(solrHome,
solrXml);
EmbeddedSolrServer newServer = new EmbeddedSolrServer(coreContainer,
myCore);
  }


Upayavira

On Sun, Jul 5, 2015, at 01:17 PM, Chaushu, Shani wrote:
> Hi,
> I'm using EmbeddedSolrServer   for testing the solr.
> I went step by step in this instuctions (for solr 4)
> https://wiki.searchtechnologies.com/index.php/Unit_Testing_with_Embedded_Solr
> I can see that the config loaded, but when I try to put document, the
> error I get is:
> org.apache.solr.common.SolrException: No such core: collection1
> 
> I'm sure it's something in the solr.xml, but I couldn't find the issue,
> Any thought?
> 
> in the solr.xml I have:
> 
> 
> 
> ${host:}
> ${jetty.port:8983}
> ${hostContext:solr}
> ${zkClientTimeout:3}
>  name="genericCoreNodeNames">${genericCoreNodeNames:true}
> 
> 
> 
> 
> 
> 
> 
> 
> 
>   class="HttpShardHandlerFactory">
> ${socketTimeout:0}
> ${connTimeout:0}
> 
> 
> 
> 
> Thanks,
> Shani
> 
> 
> -
> Intel Electronics Ltd.
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.