You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by "Erick Erickson (Confluence)" <co...@apache.org> on 2013/07/23 02:58:00 UTC

[CONF] Apache Solr Reference Guide > Format of solr.xml

Space: Apache Solr Reference Guide (https://cwiki.apache.org/confluence/display/solr)
Page: Format of solr.xml (https://cwiki.apache.org/confluence/display/solr/Format+of+solr.xml)

Added by Erick Erickson:
---------------------------------------------------------------------
You can find {{solr.xml}} in your Solr Home directory. The default _discovery_ {{solr.xml}} file looks like this:

{code:xml|borderStyle=solid|borderColor=#666666}
<solr>

  <solrcloud>
    <str name="host">${host:}</str>
    <int name="hostPort">${jetty.port:8983}</int>
    <str name="hostContext">${hostContext:solr}</str>
    <int name="zkClientTimeout">${zkClientTimeout:15000}</int>
    <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
  </solrcloud>

  <shardHandlerFactory name="shardHandlerFactory"
    class="HttpShardHandlerFactory">
    <int name="socketTimeout">${socketTimeout:0}</int>
    <int name="connTimeout">${connTimeout:0}</int>
  </shardHandlerFactory>

</solr>
{code}

As you can see, the discovery solr configuration is "SolrCloud friendly". However, the presence of the <solrcloud> element does _not_ mean that the Solr instance is running in SolrCloud mode. Unless the -DzkHost or -DzkRun are specified at startup time, this section is ignored.

h2. Using Multiple SolrCores

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 your servlet container.

Solr cores are configured by placing a file named {{core.properties}} in a subdirectory 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:
{info}
./cores/core1/core.properties
./cores/core1/coremore/core5/core.properties
{info}
The enumeration will stop at core1 in the above example.

The following is legal
{info}
./cores/somecores/core1/core.properties
./cores/somecores/core2/core.properties
./cores/othercores/core3/core.properties
./cores/extracores/deepertree/core4/core.properties
{info}

 A minimal {{core.properties}} file looks like this:

{code:xml|borderStyle=solid|borderColor=#666666}
name=collection1
{code}

This is very different than the legacy solr.xml {{<core}} tag. In fact, your core.properties file _can be empty_. Say the core.properties file is located in (relative to {{solr_home}}) ./cores/core1. In that case, the file core name is assumed to be "core1". The instance dir will be the folder containing core.properties (./cores/core1). The dataDir will be ../cores/core1/data etc.

{info}
You can run Solr without configuring any cores.
{info}

h2. Solr.xml Parameters

h3. The {{<solr>}} Element

There are no attributes that you can specify on {{<solr>}}, which is the root element of {{solr.xml}}. Here is a full example of all the possibilities in a solr.xml file with comments.
{note}
The persistent attribute is no longer supported in solr.xml. The properties in solr.xml are immutable, and any changes to individual cores are persisted in the individual core.properties files.
{note}


|| Node || Description ||
| {{code}}<str name="adminHandler"> {{code}} | If used, this attribute should be set to the FQN (Fully qualified name) of a class that inherits from CoreAdminHandler. For example, adminHandler="com.myorg.MyAdminHandler" would configure the custom admin handler (MyAdminHandler) to handle admin requests. If this attribute isn't set, Solr uses the default admin handler, org.apache.solr.handler.admin.CoreAdminHandler. For more information on this parameter, see the Solr Wiki at http://wiki.apache.org/solr/CoreAdmin#cores. |
| {{code}}<int name="coreLoadThreads">{{code}} | Specifies the number of threads that will be assigned to load cores in parallel |
| {{code}}<str name="coreRootDirectory{{code}} | The root of the core discovery tree, defaults to SOLR_HOME |
| {{code}}<str name="managementPath">{{code}} | ??? |
| {{code}}<str name="sharedLib">{{code}} | Specifies the path to a common library directory that will be shared across all cores. Any JAR files in this directory will be added to the search path for Solr plugins. This path is relative to the top-level container's Solr Home. |
| {{code}}<str name="shareSchema">{{code}} | This attribute, when set to true, ensures that the multiple cores pointing to the same schema.xml will be referring to the same IndexSchema Object. Sharing the IndexSchema Object makes loading the core faster. If you use this feature, make sure that no core-specific property is used in your schema.xml. |
| {{code}}<int name="transientCacheSize">{{code}} | Defines how many cores with transient=true that can be loaded before swapping the least recently used core for a new core. |

h3. The {{<solrcloud>}} element
This element defines several parameters that relate so SolrCloud. This section is ignored unless the solr instance is started with either -DzkRun or -DzkHost

|| Node || Description ||
| {{code}}<int name="distribUpdateConnTimeout"{{code}} | The timeout interval for distributed updates |
| {{code}}<int name="distribUpdateSoTimeout">{{code}} | ??? |
| {{code}}<str name="host">{{code}} | The hostname Solr uses to access cores. |
| {{code}}<str name="hostContext">{{code}} | The servlet context path. |
| {{code}}<int name="hostPort">{{code}} | The port Solr uses to access cores. In the default {{solr.xml}} file, this is set to {{$\{jetty.port:\}}}, which will use the Solr port defined in Jetty. |
| {{code}}<int name="leaderVoteWait">{{code}} | ??? |
| {{code}}<int name="zkClientTimeout">{{code}} | A timeout for connection to a ZooKeeper server. It is used with SolrCloud. |
| {{code}}<str name="zkHost">{{code}} | In SolrCloud mode, the URL of the ZooKeeper host that Solr should use for cluster state information. |
| {{code}}<str name="genericCoreNodeNames">{{code}} | ??? |

h3. The {{<logging>}} element.

|| Node || Description ||
| {{code}}<str name="class">{{code}} | The class to use for logging. The corresponding JAR file must be available to solr, perhaps through a <lib> directive in solrconfig.xml. |
| {{code}}<str name="enabled">{{code}} |  true/false - whether to enable logging or not. |

h4. The {{<logging><watcher>}} element.

|| Node || Description ||
| {{code}}<int name="size">{{code}} | The number of log events that are buffered. |
| {{code}}<int name="threshold">{{code}} | ??? |

h3. The {{<shardHandlerFactory}} element.

Custom share handlers can be defined in solr.xml if you wish to create a custom shard handler 

{{code}}  <shardHandlerFactory name="ShardHandlerFactory" class="qualified.class.name"> {{code}}

However, since this is a custom shard handler, sub-elements are specific to the implementation.

h3. Implicit properties
There are several properties that Solr defines automatically for each core.  These properties are described in the table below:

|| Property || Description ||
| solr.core.dataDir | The core's data directory, {{$\{solr.core.instanceDir\}/data}} by default. |
| solr.core.configName | The name of the core's configuration file, {{solrconfig.xml}} by default. |
| solr.core.schemaName | The name of the core's schema file, {{schema.xml}} by default. |

Any of the above properties can be referenced by name in {{schema.xml}} or {{solrconfig.xml}}.

When defining properties, you can assign a property a default value that will be used if another value isn't specified. For example:

Without a default value, result will be empty if the property is not defined:

{{$\{productname\}}}

With a default value:

{{$\{productname:SearchCo MegaIndex\}}}


Stop watching space: https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=solr
Change email notification preferences: https://cwiki.apache.org/confluence/users/editmyemailsettings.action