On Feb 3, 2007, at 3:43 PM, Erik Hatcher wrote:
I'd like to be able to have a common schema.xml and solrconfig.xml but be able to fire up Solr instances pointed to different data directories. I realize we have SOLR-79 in JIRA. Is that the approach we want long term?

Here's an off-the-cuff idea... what if we hook Config.get() to look for system properties that would override configuration values. SolrCore does this:

dataDir = SolrConfig.config.get("dataDir",Config.getInstanceDir() +"data");

If it looked for a system property (perhaps with a "solr." prefix) you could override anything Config serves up. Thoughts?

At first I went down the path of modifying Config.get (indirectly, by modifying Config.getVal), but it didn't feel quite right because the properties it asks for are XPaths.

dataDir is the only one I wanted to override, so I patched this instead:

Index: src/java/org/apache/solr/core/SolrCore.java
===================================================================
--- src/java/org/apache/solr/core/SolrCore.java (revision 505245)
+++ src/java/org/apache/solr/core/SolrCore.java (working copy)
@@ -182,7 +182,7 @@
       core = this;   // set singleton
       if (dataDir ==null) {
- dataDir = SolrConfig.config.get ("dataDir",Config.getInstanceDir()+"data"); + dataDir = System.getProperty("solr.dataDir", SolrConfig.config.get("dataDir",Config.getInstanceDir()+"data"));
       }
log.info("Opening new SolrCore at " + Config.getInstanceDir() + ", dataDir="+dataDir);

My use case is this: I want to have a single solrconfig.xml/ schema.xml and Solr distribution, and be able to bring up a Solr instance for different data directories. Nothing more than that. For different configurations and schemas, I'd make a copy of the configuration directory.

Does this patch make sense to commit as-is, or could it be committed with some tweaks, or is it not a good general approach and needs to be thought out more?

Thanks,
        Erik

Reply via email to