Overview
Solr allows multiple SolrCore instances to run within a single web-app. The cores can be dynamically managed via the MultiCoreHandler. For alternative ways to manage multiple indecies, see MultipleIndexes.
Configuration
To enable multi core support, place a file named multicore.xml in the solr.home directory. Here is an example multicore.xml file:
<multicore adminPath="/admin/multicore" persistent="true" sharedLib="lib"> <core name="core0" instanceDir="core0" default="true"/> <core name="core1" instanceDir="core1" /> </multicore>
multicore
The <multicore tag accepts three attributes:
adminPath
RequestHandler path to access the MultiCoreHandler for dynamic core manipulation. For example, adminPath="/admin/multicore" configures access via
http://localhost:8983/solr/admin/multicore. If this attribute is not specified, dynamic manipulation is unavailable.
persistent
By default, should runtime core manipulation be saved in multicore.xml so that it is available after a restart.
sharedLib
Path to a directory containing .jar files that are added to the classpath of every core. The path is relative to solr.home (where multicore.xml sits)
core
Each core can specify the following attributes:
name
The registered core name. This will be how the core is accessed. (required)
instanceDir
The solr.home directory for a given core. (required)
dataDir
The data directory for a given core. (optional)
default
A single core must declare default="true"
Example
Solr ships with an example multicore setup. To run this configuration, start jetty using:
java -Dsolr.solr.home=multicore -jar start.jar
This will start solr running two cores: core0, and core1. To access each core, try:
To access the admin pages for each core visit:
MultiCoreHandler
The MultiCoreHandler is a special SolrRequestHandler that is used to manage existing cores. Unlike normal SolrRequestHandlers, the MultiCoreHandler is not attached to a core, it is configured in multicore.xml. A single MultiCoreHandler exists for each web-app
To enable dynamic core configuration, make sure the adminPath attribute is set in multicore.xml. If this attribute is absent, the MultiCoreHandler will not be available.
STATUS
Get the status for a given core or all cores if no core is specified:
CREATE
Creates a new core and register it. If persistence is enabled (persist=true), the configuration for this new core will be saved in 'multicore.xml'. If a core with the same name exists, while the "new" created core is initalizing, the "old" one will continue to accept requests. Once it has finished, all new request will go to the "new" core, and the "old" core will be unloaded.
Note that config & schema parameters are optional.
LOAD
not implemented yet!
This will load a new core from an existing configuration (will be implemented when cores can be described with a lazy-load flag).
?persist=true will save the changes to multicore.xml
UNLOAD
not implemented yet!
Remove a core from solr. Existing requests will continue to be processed, but no new requests can be sent to this core.
RELOAD
Load a new core from the same configuration as an existing registered core. While the "new" core is initalizing, the "old" one will continue to accept requests. Once it has finished, all new request will go to the "new" core, and the "old" core will be unloaded.
SWAP
Change the names used to access a core