11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Substituting Properties in <strong>Solr</strong> Config Files<br />

<strong>Solr</strong> supports variable substitution of property values in config files, which allows runtime specification of various<br />

configuration options in solrconfig.xml . The syntax is ${propertyname[:option default value] }.<br />

This allows defining a default that can be overridden when <strong>Solr</strong> is launched. If a default value is not specified,<br />

then the property must be specified at runtime or the configuration file will generate an error when parsed.<br />

There are multiple methods for specifying properties that can be used in configuration files.<br />

JVM System Properties<br />

Any JVM System properties, usually specified using the -D flag when starting the JVM, can be used as variables<br />

in any XML configuration file in <strong>Solr</strong>.<br />

For example, in the sample solrconfig.xml files, you will see this value which defines the locking type to use:<br />

${solr.lock.type:native}<br />

Which means the lock type defaults to "native" but when starting <strong>Solr</strong>, you could override this using a JVM<br />

system property by launching the <strong>Solr</strong> it with:<br />

bin/solr start -Dsolr.lock.type=none<br />

In general, any Java system property that you want to set can be passed through the bin/solr script using the<br />

standard -Dproperty=value syntax. Alternatively, you can add common system properties to the SOLR_OPTS<br />

environment variable defined in the <strong>Solr</strong> include file ( bin/solr.in.sh). For more information about how the<br />

<strong>Solr</strong> include file works, refer to: Taking <strong>Solr</strong> to Production.<br />

solrcore.properties<br />

If the configuration directory for a <strong>Solr</strong> core contains a file named solrcore.properties that file can contain<br />

any arbitrary user defined property names and values using the Java standard properties file format, and those<br />

properties can be used as variables in the XML configuration files for that <strong>Solr</strong> core.<br />

For example, the following solrcore.properties file could be created in the conf/ directory of a collection<br />

using one of the example configurations, to override the lockType used.<br />

#conf/solrcore.properties<br />

solr.lock.type=none<br />

The path and name of the solrcore.properties file can be overridden using the properties prop<br />

erty in core.properties.<br />

User defined properties from core.properties<br />

If you are using a core.properties file with solr.xml, then any user defined properties in that file may be<br />

specified there and those properties will be available for substitution when parsing XML configuration files for that<br />

<strong>Solr</strong> core.<br />

For example, consider the following core.properties file:<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

436

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!