Core Discovery
Core discovery means that creating a core is as simple as a core.properties
file located on disk.
The core.properties File
In Solr, the term core is used to refer to a single index and associated transaction log and configuration files (including the solrconfig.xml
and schema files, among others).
Your Solr installation can have multiple cores if needed, which allows you to index data with different structures in the same server, and maintain control over how your data is presented to different audiences.
In SolrCloud mode you will be more familiar with the term collection.
Behind the scenes a collection consists of one or more cores.
Cores can be created using bin/solr
script or as part of SolrCloud collection creation using the APIs.
Core-specific properties (such as the directories to use for the indexes or configuration files, the core name, and other options) are defined in a core.properties
file.
Any core.properties
file in any directory of your Solr installation (or in a directory under where solr_home
is defined) will be found by Solr and the defined properties will be used for the core named in the file.
The core.properties
file is a simple Java Properties file where each line is just a key=value pair, e.g., name=core1
.
Notice that no quotes are required.
A minimal core.properties
file looks like the example below.
However, it can also be empty, see information on placement of core.properties
below.
name=my_core_name
Placement of core.properties
Solr cores are configured by placing a file named core.properties
in a sub-directory under solr.home
.
There are no a-priori limits to the depth of the tree, nor are there limits to the number of cores that can be defined.
Cores may be anywhere in the tree with the exception that cores may not be defined under an existing core.
That is, the following is not allowed:
./cores/core1/core.properties
./cores/core1/coremore/core5/core.properties
In this example, the enumeration will stop at "core1".
The following is legal:
./cores/somecores/core1/core.properties
./cores/somecores/core2/core.properties
./cores/othercores/core3/core.properties
./cores/extracores/deepertree/core4/core.properties
It is possible to segment Solr into multiple cores, each with its own configuration and indices. Cores may be dedicated to a single application or to very different ones, but all are administered through a common administration interface. You can create new Solr cores on the fly, shutdown cores, even replace one running core with another, all without ever stopping or restarting Solr.
Your core.properties
file can be empty if necessary.
Suppose core.properties
is located in ./cores/core1
(relative to solr_home
) but is empty.
In this case, the core name is assumed to be "core1".
The instanceDir will be the folder containing core.properties
(i.e., ./cores/core1
).
The dataDir will be ../cores/core1/data
, etc.
You can run Solr without configuring any cores. |
Defining core.properties Files
The minimal core.properties
file is an empty file, in which case all of the properties are defaulted appropriately.
Java properties files allow the hash (#
) or bang (!
) characters to specify comment-to-end-of-line.
The following properties are available:
name
-
Optional
Default: none
The name of the SolrCore. You’ll use this name to reference the SolrCore when running commands with the
CoreAdminHandler
. config
-
Optional
Default:
solrconfig.xml
The configuration file name for a given core.
schema
-
Optional
Default: see description
The schema file name for a given core. The default is
schema.xml
but please note that if you are using a "managed schema" (the default behavior) then any value for this property which does not match the effectivemanagedSchemaResourceName
will be read once, backed up, and converted for managed schema use. See Schema Factory Configuration for more details. dataDir
-
Optional
Default:
data
The core’s data directory (where indexes are stored) as either an absolute pathname, or a path relative to the value of
instanceDir
. configSet
-
Optional
Default: none
The name of a defined configset, if desired, to use to configure the core (see the section Configsets for more details).
properties
-
Optional
Default: none
The name of the properties file for this core. The value can be an absolute pathname or a path relative to the value of
instanceDir
. transient
-
Optional
Default:
false
When
true
, the core can be unloaded if Solr reaches thetransientCacheSize
. Cores are unloaded in order of least recently used first. Setting this totrue
is not recommended in SolrCloud mode. loadOnStartup
-
Optional
Default:
true
When
true
, the default, the core will loaded when Solr starts. Setting this tofalse
is not recommended in SolrCloud mode. coreNodeName
-
Optional
Default: see description
Used only in SolrCloud, this is a unique identifier for the node hosting this replica. By default a
coreNodeName
is generated automatically, but setting this attribute explicitly allows you to manually assign a new core to replace an existing replica. For example, this can be useful when replacing a machine that has had a hardware failure by restoring from backups on a new machine with a new hostname or port. ulogDir
-
Optional
Default: none
The absolute or relative directory for the update log for this core (SolrCloud only).
shard
-
Optional
Default: none
The shard to assign this core to (SolrCloud only).
collection
-
Optional
Default: none
The name of the collection this core is part of (SolrCloud only).
roles
-
Optional
Default: none
Future parameter for SolrCloud or a way for users to mark nodes for their own use.
Additional user-defined properties may be specified for use as variables. For more information on how to define local properties, see the section Property Substitution in Configuration Files.