I've found two ways which allow me to load all the config files from a
jar file, however with the first solution I cannot specify the dataDir.

This is the first way:

System.setProperty("solr.solr.home", solrHome);
CoreContainer.Initializer initializer =
  new CoreContainer.Initializer();
CoreContainer coreContainer =
  initializer.initialize();
EmbeddedSolrServer server =
  new EmbeddedSolrServer(coreContainer, coreName);

This is what http://wiki.apache.org/solr/Solrj suggests, however using
this way it's not possible to specify the dataDir which is, by default,
${solr.solr.home}/data/index.


This is my attempt to do the same, but in a way I can specify the
dataDir:

System.setProperty("solr.solr.home", solrHome);
System.setProperty("solr.core.dataDir", dataDir);
CoreContainer coreContainer = new CoreContainer();
SolrConfig solrConfig = new SolrConfig();
IndexSchema indexSchema =
  new IndexSchema(solrConfig, null, null);
SolrCore core =
  new SolrCore(dataDir, indexSchema);
core.setName(coreName);
coreContainer.register(core, false);
EmbeddedSolrServer server =
  new EmbeddedSolrServer(coreContainer, coreName);


Do you see any problems with the second solution?

Is there a better way?

Paolo

Paolo Castagna wrote:
Hi,
I am trying to use EmbeddedSolrServer with just one core and I'd like to
load solrconfig.xml, schema.xml and other configuration files from a jar
via getResourceAsStream(...).

I've tried to use SolrResourceLoader, but all my attempts failed with a
RuntimeException: Can't find resource [...].

Is it possible to construct an EmbeddedSolrServer loading all the config
files from a jar file?

Thank you in advance for your help,
Paolo

Reply via email to