pvgoddijn
pvgoddijn

Reputation: 12898

Solr (4.4+) solrconfig.xml location when creating cores

I'm Trying to setup a multi core solr server for our webapplication but i'm having trouble creating new core through the coreadmin service.

I'm using Solr-4.4 because 4.3 ran into problems persisting the cores in solr.xml (datadir wasn't preserved) So i'm using the new Solr.xml configuration 4.4 and beyond

My solr.xml currently looks like:

<solr>
  <str name="coreRootDirectory">default-instance/cores/</str>
</solr>

solrconfig.xml is located at (solrhome)/default-instance/conf/solrconfig.xml

When trying to create a core with the url

http:/example.org/solr/admin/cores?action=CREATE&name=test-name&schema=schema-test.xml&loadOnStartup=false

gives me the error:

Error CREATEing SolrCore 'test-name': Unable to create core: test-name Caused by: Can't find resource 'solrconfig.xml' in classpath or 'default-instance/cores/test-name/conf/', cwd=/var/lib/tomcat7

The following seems to work:

http:/example.org/solr/admin/cores?action=CREATE&name=test-name&schema=schema-test.xml&loadOnStartup=false&config=/absolute/file/path/to/solrconfig.xml

The problem is this only seems to work with a absolute path (or possibly a relative path from /var/lib/tomcat7) which is not a workable solution.

What i'm looking for is a way to place solrconfig.xml so it can be used to create new cores with that config (or a way the create those cores with the current location).

More or less the same will be needed for schemas

Upvotes: 6

Views: 18147

Answers (4)

Simon
Simon

Reputation: 857

I recommend the new Config Sets for this use case.

If you place your schema.xml and solrconfig.xml (and other config files like stopwords etc.) in a directory $SOLR_HOME/configsets/myConfig/conf, you can create a new core with this config by calling:

http://solr/admin/cores?action=CREATE&name=mycore&instanceDir=my_instance&configSet=myConfig

See https://cwiki.apache.org/confluence/display/solr/Config+Sets

But they are not available until Solr 4.8, see https://issues.apache.org/jira/browse/SOLR-4478

Upvotes: 2

Andrew Betts
Andrew Betts

Reputation: 336

This worked. Ran on command line and was viewable in admin console:

solr create -c (name for core or collection)

See README.txt for more info.

Upvotes: 10

mydoghasworms
mydoghasworms

Reputation: 18591

In my case I took advantage of the Core Discovery feature in 4.4+, rather than creating the core using the management web interface.

This simply involved copying the example collection1 folder from the examples directory (which I usually use as a starting point).

Then I had to make sure that there is core.properties in the root of my new core with name=<new core name> inside. Solr automatically detected the new core and allowed me to use it without any fuss.

This avoided the trouble of having to copying solrconfig.xml and schema.xml into any special location.

Upvotes: 4

helt
helt

Reputation: 5197

I had the same problem: solrconfig.xml was not in the classpath. I solved it by copying my configuration file templates into the classpath.

So I took a look at http://localhost:8983/solr/#/~java-properties to see solrs classpath definition and then i copied the template solrconfig.xml and schema.xml into the folder C:\servers\solr-4.4.0\example\resources. Furthermore i copied all the stopwords stuff there...

This solution is not a fully satisfying, but it works. Adding another path to the classpath should work, too. I'm slightly astonished that no default configuration for new cores can be declared within solr.xml

Upvotes: 2

Related Questions