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/24 00:29:00 UTC

[CONF] Apache Solr Reference Guide > Legacy solr.xml Configuration

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

Change Comment:
---------------------------------------------------------------------
remove mention of solrconfig.xml implicit properties -- these are now on the solrconfig.xml page - add explanation of what sys props can be used in solr.xml

Edited by Hoss Man:
---------------------------------------------------------------------
Use {{solr.xml}} to configure your Solr core (a logical index and associated configuration files), or to configure multiple cores. You can find {{solr.xml}} in your Solr Home directory. The default {{solr.xml}} file looks like this:

{code:xml|borderStyle=solid|borderColor=#666666}
<solr persistent="true">
  <cores adminPath="/admin/cores" defaultCoreName="collection1" host="${host:}"
         hostPort="${jetty.port:}" hostContext="${hostContext:}"
         zkClientTimeout="${zkClientTimeout:15000}">
    <core name="collection1" instanceDir="collection1" />
  </cores>
</solr>
{code}

For more information about core configuration and {{solr.xml}}, see [http://wiki.apache.org/solr/CoreAdmin].

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 {{solr.xml}} in your {{solr.home}} directory. A typical {{solr.xml}} looks like this:

{code:xml|borderStyle=solid|borderColor=#666666}
<solr persistent="false">
  <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:}">
    <core name="core0" instanceDir="core0" />
    <core name="core1" instanceDir="core1" />
  </cores>
</solr>
{code}

This sets up two Solr cores, named "core0" and "core1", and names the directories (relative to the Solr installation path) which will store the configuration and data sub-directories.

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

h2. Solr.xml Parameters

h3. The {{<solr>}} Element

There are several attributes that you can specify on {{<solr>}}, which is the root element of {{solr.xml}}.

|| Attribute || Description ||
| {{coreLoadThreads}} | Specifies the number of threads that will be assigned to load cores in parallel |
| {{persistent}} | Indicates that changes made through the API or admin UI should be saved back to this {{solr.xml}}. If not {{true}}, any runtime changes will be lost on the next Solr restart. The servlet container running Solr must have sufficient permissions to replace {{solr.xml}} (file delete and create), or errors will result. Any comments in {{solr.xml}} are not preserved when the file is updated. The default is true. |
| {{sharedLib}} | 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. |
| {{zkHost}} | In SolrCloud mode, the URL of the ZooKeeper host that Solr should use for cluster state information. |

{note}
If you set the persistent attribute to *true*, be sure that the Web server has permission to replace the file. If the permissions are set incorrectly, the server will generate 500 errors and throw IOExceptions. Also, note that any comments in the {{solr.xml}} file will be lost when the file is overwritten.
{note}

h3. The {{<cores>}} Element

The {{<cores>}} element, which contains definitions for each Solr core, is a child of {{<solr>}} and accepts several attributes of its own.

|| Attribute || Description ||
| {{adminPath}} | This is the relative URL path to access the SolrCore administration pages. For example, a value of {{/admin/cores}} means that you can access the CoreAdminHandler with a URL that looks like this: [http://localhost:8983/solr/admin/cores]. If this attribute is not present, then SolrCore administration will not be possible. |
| {{host}} | The hostname Solr uses to access cores. |
| {{hostPort}} | 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. |
| {{hostContext}} | The servlet context path. |
| {{zkClientTimeout}} | A timeout for connection to a ZooKeeper server. It is used with [solr:SolrCloud]. |
| {{distribUpdateConnTimeout}} | Used to set the underlying "connTimeout" for intra-cluster updates. |
| {{distribUpdateSoTimeout}} | Used to set the underlying "socketTimeout" for intra-cluster updates |
| {{leaderVoteWait}} | When SolrCloud is starting up, how long each Solr node will wait for all known replicas for that share to be found before assuming that any nodes that haven't reported are down. |
| {{genericCoreNodeNames}} | If {{TRUE}}, node names are not based on the address of the node, but on a generic name that identifies the core. When a different machine takes over serving that core things will be much easier to understand. |
| {{managementPath}} | no-op at present.  |
| {{defaultCoreName}} | The name of a core that will be used for requests that do not specify a core. |
| {{transientCacheSize}} | Defines how many cores with {{transient=true}} that can be loaded before swapping the least recently used core for a new core. |
| {{shareSchema}} | 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}}. |
| {{adminHandler}} | 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]. |

h3. The {{<logging>}} Element

There is at most one {{<logging>}} element for a Solr installation that defines various attributes for logging.

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

In addition, the {{<logging>}} element may have a child element {{<watcher>}} which may have the following attributes
| {{size}} | The number of log events that are buffered. |
| {{threshold}} | The logging level above which your particular logging implementation will record. For example when using log4j one might specify DEBUG or WARN or INFO etc. |

h3. The <core> Element

There is one {{<core>}} element for each SolrCore you define. They are children of the {{<cores>}} element and each one accepts the following attributes.

|| Attribute || Description ||
| {{name}} | The name of the SolrCore.  You'll use this name to reference the SolrCore when running commands with the CoreAdminHandler. |
| {{instanceDir}} | This relative path defines the Solr Home for the core. |
| {{config}} | The configuration file name for a given core. The default is {{solrconfig.xml}}. |
| {{schema}} | The schema file name for a given core. The default is {{schema.xml}} |
| {{dataDir}} | This relative path defines the Solr Home for the core. |
| {{properties}} | 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}} | If *true*, the core can be unloaded if Solr reaches the {{transientCacheSize}}. The default if not specified is *false*. Cores are unloaded in order of least recently used first. |
| {{loadOnStartup}} | If *true*, the default if it is not specified, the core will loaded when Solr starts. |
| {{coreNodeName}} | Added in Solr 4.2, this attributes allows naming a core. The name can then be used later if you need to replace a machine with a new one. By assigning the new machine the same coreNodeName as the old core, it will take over for the old SolrCore. |
| {{ulogDir}} | The absolute or relative directory for the update log for this core (SolrCloud) |
| {{shard}} | The shard to assign this core to (SolrCloud) |
| {{collection}} | The name of the collection this core is part of (SolrCloud) |
| {{roles}} | Future param for SolrCloud or a way for users to mark nodes for their own use. |


h3. Substituting JVM System Properties in {{solr.xml}}

Solr supports variable substitution of JVM system property values in {{solr.xml}}, which allows runtime specification of various configuration options. 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 solr.xml file will generate an error when parsed.

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

For example: In the {{solr.xml}} file shown below, starting solr using {{java -Dmy.logging=true -jar start.jar}} will cause the {{enabled}} option of the log watcher to be overridden using a value of {{true}}, instead of the default property value of "false" -- however the {{threshold}} option will continue to use the default property value of "INFO".

{code:xml|borderStyle=solid|borderColor=#666666}
<solr persistent="true">
  <logging enabled="${my.logging:false}">
    <watcher size="100" threshold="${my.logging.level:INFO}" />
  </logging>
  <cores adminPath="/admin/cores">
    <core name="collection1" instanceDir="collection1" />
  </cores>
</solr>
{code}

h3. User Defined Properties in {{solr.xml}}

You can define custom properties in {{solr.xml}} that you may then [reference in {{solrconfig.xml}} and {{schema.xml}}|Configuring solrconfig.xml#SubstitutingPropertiesinSolrConfigFiles]. Properties are name/value pairs. The scope of a property depends on which element it occurs within.

If a property is declared under {{<solr>}} but outside a {{<core>}} element, then it will have container scope and will be visible to all cores. In the example above, {{productname}} is such a property.

If a property declaration occurs within a {{<core>}} element, then its scope is limited to that core and it will not be visible to other cores. A property at core scope will override one of the same name declared at container scope.

{code:borderStyle=solid|borderColor=#666666}
<solr persistent="true" sharedLib="lib">
     <property name="productname" value="Acme Online"/>
     <cores adminPath="/admin/cores">
        <core name="core0" instanceDir="core0">
             <property name="dataDir" value="/data/core0"/></core>
        <core name="core1" instanceDir="core1"/>
    </cores>
</solr>
{code}

{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