We have a situation where we have to maybe create multiple instances of Solr/Tomcat running on different ports on either a single machine or several different machines. Towards doing this I was wondering if it's possible to specify the dataDir variable (within solrconfig.xml) using an environmentvariable for example like so: <dataDir>${envvar}/path/to/index</dataDir>
.
Yes, you can do this, but you need to do jump through a couple hoops to set this up using system properties passed to the JVM when you start it.
Anywhere you want your environment variable to work in your configuration files, put the variable like this:
${VAR}
Then, when you start your JVM, pass it the variable by doing:
java -DVAR=$your-system-variable
So, to make this concrete, here's what we do:
java -DINSTALL_ROOT=$INSTALL_ROOT -jar -server start.jar
And our config has something like:
<filter class="solr.SynonymFilterFactory" synonyms=${INSTALL_ROOT}/Solr/conf/synonyms.txt />
Works like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With