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

[CONF] Apache Solr Reference Guide > Configuring solrconfig.xml

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

Change Comment:
---------------------------------------------------------------------
better flesh out the details on where property value substitutions can come from

Edited by Hoss Man:
---------------------------------------------------------------------
The {{solrconfig.xml}} file is the configuration file with the most parameters affecting Solr itself. While configuring Solr, you'll work with {{solrconfig.xml}} often. The file comprises a series of XML statements that set configuration values. In {{solrconfig.xml}}, you configure important features such as:

* request handlers

* listeners (processes that "listen" for particular query-related events; listeners can be used to trigger the execution of special code, such as invoking some common queries to warm-up caches)

* the Request Dispatcher for managing HTTP communications

* the Admin Web interface

* parameters related to replication and duplication (these parameters are covered in detail in [Legacy Scaling and Distribution])

The {{solrconfig.xml}} file is found in the {{solr/conf/}} directory. The example file is well-commented, and includes information on best practices for most installations.

We've covered the options in the following sections:

{children:depth=1}

h2. Substituting Properties in Solr Config Files

Solr supports variable substitution of property values in config files, which allows runtime specification of various configuration options in {{solrconfig.xml}}. The syntax is {{$\{propertyname\[:option default value\]\}}}. This allows defining a default that can be overridden when Solr is launched.  If a default value is not specified, then the property _must_ be specified at runtime or the configuration file will generate an error when parsed.

There are multiple methods for specifying properties that can be used in configuration files.

h3. JVM System Properties

Any JVM System properties, usually specified using the {{-D}} flag when starting the JVM, can be used as variables in any XML configuration file in Solr.

For example, in the example {{solrconfig.xml}}, you will see this value which defines the locking type to use:

{code:xml|borderStyle=solid|borderColor=#666666}
   <lockType>${solr.lock.type:native}</lockType>
{code}

Which means the lock type defaults to "native" but when starting Solr's example application, you could override this by launching the JVM it with:

{code:borderStyle=solid|borderColor=#666666}
java -Dsolr.lock.type=simple -jar start.jar
{code}

h3. {{solrcore.properties}}

If the configuration directory for a Solr core contains a file named {{solrcore.properties}} that file can contain any arbitrary user defined property names and values using the Java standard [properties file format|https://en.wikipedia.org/wiki/.properties], and those properties can be used as variables in the XML configuration files for that Solr core.

For example, the following {{solrcore.properties}} file could be created in the {{solr/collection1/conf}} directory of the Solr example configuration, to specify the lockType used.

{code:borderStyle=solid|borderColor=#666666}
#conf/solrcore.properties
lock.type=simple
{code}

{note}
The path and name of the {{solrcore.properties}} file can be overridden using the [{{properties}} property in {{core.properties}}|Format of Solr.xml#Formatofsolr.xml-Individual{{core.properties}}Files]
{note}

h3. User defined properties from {{core.properties}}

If you are using the newer [core discovery style solr.xml|Format of solr.xml] such that each Solr core has a core.properties file, then any _user defined_ properties in that file may be specified there and those properties will be available for substitution when parsing XML configuration files for that Solr core.

For example, consider the following {{core.properties}} file:

{code:borderStyle=solid|borderColor=#666666}
#core.properties
name=collection2
my.custom.prop=edismax
{code}

the {{my.custom.prop}} property can be used as a variable, like so...

{code:xml|borderStyle=solid|borderColor=#666666}
  <requestHandler name="/select">
    <lst name="defaults">
      <str name="defType">${my.custom.prop}</str>
    </lst>
  </requestHandler>
{code}

h3. Implicit Core Properties

Several attributes of a Solr core are available as "implicit" properties that can be used in variable substitution, independent of where or how they underlying value is initialized.  For example: regardless of whether the name for a particular Solr core is explicitly configured in {{core.properties}} or inferred from the name of the instance directory, the implicit property {{solr.core.name}} is available for use as a variable in that core's configuration file...

{code:xml|borderStyle=solid|borderColor=#666666}
  <requestHandler name="/select">
    <lst name="defaults">
      <str name="collection_name">${solr.core.name}</str>
    </lst>
  </requestHandler>
{code}

All implicit properties use the {{solr.core.}} name prefix, and reflect the runtime value of the equivalent [{{core.properties}} property|Format of Solr.xml#Formatofsolr.xml-Individual{{core.properties}}Files]:

 * {{solr.core.name}}
 * {{solr.core.config}}
 * {{solr.core.schema}}
 * {{solr.core.dataDir}}
 * {{solr.core.transient}}
 * {{solr.core.loadOnStartup}}

h2. More Information 

* The Solr Wiki has a comprehensive page on {{solrconfig.xml}}, at [http://wiki.apache.org/solr/SolrConfigXml].
* [6 Sins of solrconfig.xml modifications|http://solr.pl/en/2010/09/13/6-sins-of-solrconfig-xml-modifications/] from solr.pl.

{scrollbar}


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