DataDir and DirectoryFactory in SolrConfig

Where and how Solr stores its indexes are configurable options.

Specifying a Location for Index Data with the dataDir Parameter

By default, Solr stores its index data in a directory called /data under the core’s instance directory (instanceDir). If you would like to specify a different directory for storing index data, you can configure the dataDir in the file for the core, or use the <dataDir> parameter in the solrconfig.xml file. You can specify another directory either with an absolute path or a pathname relative to the instanceDir of the SolrCore. For example:


The ${} substitution will cause the name of the current core to be substituted, which results in each core’s data being kept in a separate subdirectory.

If you are using replication to replicate the Solr index (as described in Legacy Scaling and Distribution), then the <dataDir> directory should correspond to the index directory used in the replication configuration.

If the environment variable SOLR_DATA_HOME is defined, or if is configured for your DirectoryFactory, or if solr.xml contains an element <solrDataHome> then the location of data directory will be <SOLR_DATA_HOME>/<instance_name>/data.

Specifying the DirectoryFactory For Your Index

The default solr.NRTCachingDirectoryFactory is filesystem based, and tries to pick the best implementation for the current JVM and platform. You can force a particular implementation and/or config options by specifying solr.MMapDirectoryFactory, solr.NIOFSDirectoryFactory, or solr.SimpleFSDirectoryFactory.

<directoryFactory name="DirectoryFactory"
  <bool name="preload">true</bool>

The solr.RAMDirectoryFactory is memory based, not persistent, and does not work with replication. Use this DirectoryFactory to store your index in RAM.

<directoryFactory class="org.apache.solr.core.RAMDirectoryFactory"/>

If you are using Hadoop and would like to store your indexes in HDFS, you should use the solr.HdfsDirectoryFactory instead of either of the above implementations. For more details, see the section Running Solr on HDFS.

Comments on this Page

We welcome feedback on Solr documentation. However, we cannot provide application support via comments. If you need help, please send a message to the Solr User mailing list.