EmbeddedSolrServer in Single Core

2009-01-09 Thread qp19

Please bear with me. I am new to Solr. I have searched all the existing posts
about this and could not find an answer. I wanted to know how do I go about
creating a 

SolrServer using EmbeddedSolrServer. I tried to initialize this several ways
but was unsuccesful. I do not have multi-core. I am using solrj 1.3. I
attempted to use the 

depracated methods as mentioned in the SolrJ documentation the following way
but it fails as well with unable to locate Core.


 SolrCore core = SolrCore.getSolrCore();
  SolrServer server = new EmbeddedSolrServer( core );

So far my installation is pretty basic with Solr running on Tomcat as per
instructions in the wiki. My solr home is outside of webapps folder i.e
c:/tomcat-solr/solr. I am 

able to connect using CommonsHttpSolrServer(http://localhost:8080/solr;)
without a problem. The question in a nutshell is, how do I instantiate
EmbeddedSolrServer using  new EmbeddedSolrServer(CoreContainer
coreContainer, String coreName) ? Initializing CoreContainer appears to be
complicated when compared to SolrCore.getSolrCore() as per the examples. Is
there a simpler way to Initialize CoreContainer? Is a core(or CoreName)
necessary eventhough I don't use multi-core? Also, is it possible to
initialize EmbeddedSolrServer using spring? Thanks in advance for the help.


-- 
View this message in context: 
http://www.nabble.com/EmbeddedSolrServer-in-Single-Core-tp21383525p21383525.html
Sent from the Solr - User mailing list archive at Nabble.com.



Re: EmbeddedSolrServer in Single Core

2009-01-09 Thread Ryan McKinley


On Jan 9, 2009, at 8:12 PM, qp19 wrote:



Please bear with me. I am new to Solr. I have searched all the  
existing posts
about this and could not find an answer. I wanted to know how do I  
go about

creating a

SolrServer using EmbeddedSolrServer. I tried to initialize this  
several ways

but was unsuccesful. I do not have multi-core. I am using solrj 1.3. I
attempted to use the

depracated methods as mentioned in the SolrJ documentation the  
following way

but it fails as well with unable to locate Core.


SolrCore core = SolrCore.getSolrCore();


This function is deprecated and *really* should no be used --  
especially for embedded solr server.  (the only chance you would have  
for it to work is if you start up solr in a web app before calling this)




 SolrServer server = new EmbeddedSolrServer( core );



Core initialization is kind of a mess, but this contains everything  
you would need:


  CoreContainer container = new CoreContainer(new  
SolrResourceLoader(SolrResourceLoader.locateInstanceDir()));
  CoreDescriptor dcore = new CoreDescriptor(container, coreName,  
solrConfig.getResourceLoader().getInstanceDir());

  dcore.setConfigName(solrConfig.getResourceName());
  dcore.setSchemaName(indexSchema.getResourceName());
  SolrCore core = new SolrCore( null, dataDirectory, solrConfig,  
indexSchema, dcore);

  container.register(coreName, core, false);



So far my installation is pretty basic with Solr running on Tomcat  
as per
instructions in the wiki. My solr home is outside of webapps folder  
i.e

c:/tomcat-solr/solr. I am

able to connect using CommonsHttpSolrServer(http://localhost:8080/solr 
)

without a problem. The question in a nutshell is, how do I instantiate
EmbeddedSolrServer using  new EmbeddedSolrServer(CoreContainer
coreContainer, String coreName) ? Initializing CoreContainer appears  
to be
complicated when compared to SolrCore.getSolrCore() as per the  
examples. Is
there a simpler way to Initialize CoreContainer? Is a core(or  
CoreName)

necessary eventhough I don't use multi-core? Also, is it possible to
initialize EmbeddedSolrServer using spring? Thanks in advance for  
the help.




yes, I use this:


  bean id=multiCore class=org.apache.solr.core.CoreContainer
constructor-argvalue${dir}/value/constructor-arg
constructor-argvalue${dconfigFile}/value/constructor-arg
  /bean

  bean id=solrFlat  
class=org.apache.solr.client.solrj.embedded.EmbeddedSolrServer

constructor-arg ref=multiCore /
constructor-arg value=flat /
  /bean

  bean id=solrSuggest  
class=org.apache.solr.client.solrj.embedded.EmbeddedSolrServer

constructor-arg ref=multiCore /
constructor-arg value=suggest /
  /bean


ryan