When using EmbeddedSolrServer, you could simply set the solr.data.dir
system property or launch your process from the same working directory
where you are launching the HTTP version of Solr. Either of those
should also work to alleviate this issue.
Erik
On Feb 12, 2010, at 5:36 AM, dcdmailbox-i...@yahoo.it wrote:
Yes you are right.
[code.2] works fine by commenting out the following lines on
solrconfig.xml
<!--
Used to specify an alternate directory to hold all index data
other than the default ./data under the Solr home.
If replication is in use, this should match the replication
configuration.
-->
<!--
<dataDir>${solr.data.dir:./solr/data}</dataDir>
-->
Is it correct this different behaviour from EmbeddedSolrServer ?
Or it can be considered a low priority bug?
Thanks for you prompt reply!
Dino.
--
________________________________
Da: Ron Chan <rc...@i-tao.com>
A: solr-user@lucene.apache.org
Inviato: Ven 12 febbraio 2010, 11:14:58
Oggetto: Re: EmbeddedSolrServer vs CommonsHttpSolrServer
I suspect this has something to do with the dataDir setting in the
example 's solrconfig.xml
<dataDir>${solr.data.dir:./solr/data}</dataDir>
we use the example's solrconfig.xml as the base for our deployments
and always comment this out
the default of having conf and data sitting under the solr home
works well
----- Original Message -----
From: dcdmailbox-i...@yahoo.it
To: solr-user@lucene.apache.org
Sent: Friday, 12 February, 2010 8:30:57 AM
Subject: EmbeddedSolrServer vs CommonsHttpSolrServer
Hi all,
I am new to solr/solrj.
I correctly started up the server example given in the distribution
(apache-solr-1.4.0\example\solr), populated the index with test data
set, and successfully tested with http query string via browser (es. http://localhost:8983/solr/select/?indent=on&q=video&fl=name,id)
I am trying to set up solrj clients using both CommonsHttpSolrServer
and EmbeddedSolrServer.
My examples are with single core configuration.
Here below the method used for CommonsHttpSolrServer initialization:
[code.1]
public SolrServer getCommonsHttpSolrServer() throws IOException,
ParserConfigurationException, SAXException, SolrServerException {
String url = "http://localhost:8983/solr";
CommonsHttpSolrServer server = new CommonsHttpSolrServer(url);
server.setSoTimeout(1000); // socket read timeout
server.setConnectionTimeout(100);
server.setDefaultMaxConnectionsPerHost(100);
server.setMaxTotalConnections(100);
server.setFollowRedirects(false); // defaults to false
// allowCompression defaults to false.
// Server side must support gzip or deflate for this to have any
effect.
server.setAllowCompression(true);
server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
return server;
}
Here below the method used for EmbeddedSolrServer initialization
(provided in the wiki section):
[code.2]
public SolrServer getEmbeddedSolrServer() throws IOException,
ParserConfigurationException, SAXException, SolrServerException {
System.setProperty("solr.solr.home", "/WORKSPACE/bin/apache-
solr-1.4.0/example/solr");
CoreContainer.Initializer initializer = new
CoreContainer.Initializer();
CoreContainer coreContainer = initializer.initialize();
EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, "");
return server;
}
Here below the common code used to query the server:
[code.3]
SolrServer server = mintIdxMain.getEmbeddedSolrServer();
//SolrServer server = mintIdxMain.getCommonsHttpSolrServer();
SolrQuery query = new SolrQuery("video");
QueryResponse rsp = server.query(query);
SolrDocumentList docs = rsp.getResults();
System.out.println("Found : " + docs.getNumFound());
System.out.println("Start : " + docs.getStart());
System.out.println("Max Score: " + docs.getMaxScore());
CommonsHttpSolrServer gives correct results whereas
EmbeddedSolrServer gives always no results.
What's wrong with the initialization and/or the configuration of the
EmbeddedSolrServer?
CoreContainer.Initializer() seems to not recognize the single core
from solrconfig.xml...
If I modify [code.2] with the following code, it seems to work.
I manually added only explicit Core Container registration.
Is [code.4] the correct way?
[code.4]
public SolrServer getEmbeddedSolrServer() throws IOException,
ParserConfigurationException, SAXException, SolrServerException {
System.setProperty("solr.solr.home", "/WORKSPACE/bin/apache-
solr-1.4.0/example/solr");
CoreContainer.Initializer initializer = new
CoreContainer.Initializer();
CoreContainer coreContainer = initializer.initialize();
/* >>>>> */
SolrConfig solrConfig = new SolrConfig("/WORKSPACE/bin/apache-
solr-1.4.0/example/solr", "solrconfig.xml", null);
IndexSchema indexSchema = new IndexSchema(solrConfig, "schema.xml",
null);
CoreDescriptor coreDescriptor = new CoreDescriptor(coreContainer,
"", solrConfig.getResourceLoader().getInstanceDir());
SolrCore core = new SolrCore(null, "/WORKSPACE/bin/apache-solr-1.4.0/
example/solr/data", solrConfig, indexSchema, coreDescriptor);
coreContainer.register("", core, false);
/* <<<<< */
EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, "");
return server;
}
Many thanks in advance for the support and the great work realized
with all the lucene/solr projects.
Dino.
--