On Jun 12, 2007, at 12:37 PM, Ryan McKinley wrote:
Erik Hatcher wrote:
On Jun 12, 2007, at 1:34 AM, Ryan McKinley wrote:
- <!--
- <dataDir>./solr/data</dataDir>
- -->
+ <dataDir>${solr.data.dir:./solr/data}</dataDir>
+
I just ran into something weird with this...
If you set the solr home with JNDI or solr.solr.home, the dataDir
still defaults to "./solr/data" -- not the data directory
relative to solr home. This requires you to *also* set:
"solr.data.dir" if you want to use a different data directory.
I think we should comment it out so that the by default, setting
solr home moves everything.
Instead, maybe a relative path should be made relative to Solr's
home directory instead of to the current working directory?
that sounds good.
It is nice to be able to set the data directory with a property...
Does this patch work for you, Ryan?
Index: src/java/org/apache/solr/core/SolrCore.java
===================================================================
--- src/java/org/apache/solr/core/SolrCore.java (revision 546568)
+++ src/java/org/apache/solr/core/SolrCore.java (working copy)
@@ -17,6 +17,8 @@
package org.apache.solr.core;
+import static org.apache.solr.core.Config.getInstanceDir;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -73,8 +75,8 @@
public static Logger log = Logger.getLogger(SolrCore.class.getName
());
private final IndexSchema schema;
- private final String dataDir;
- private final String index_path;
+ private final File dataDir;
+ private final File index_path;
private final UpdateHandler updateHandler;
private static final long startTime = System.currentTimeMillis();
private final RequestHandlers reqHandlers = new RequestHandlers();
@@ -114,8 +116,8 @@
}
public IndexSchema getSchema() { return schema; }
- public String getDataDir() { return dataDir; }
- public String getIndexDir() { return index_path; }
+ public String getDataDir() { return dataDir.getAbsolutePath(); }
+ public String getIndexDir() { return index_path.getAbsolutePath(); }
// gets a non-caching searcher
public SolrIndexSearcher newSearcher(String name) throws
IOException {
@@ -187,18 +189,19 @@
core = this; // set singleton
if (dataDir ==null) {
- dataDir = SolrConfig.config.get
("dataDir",Config.getInstanceDir()+"data");
+ dataDir = SolrConfig.config.get("dataDir", getInstanceDir()
+"data");
}
- log.info("Opening new SolrCore at " + Config.getInstanceDir()
+ ", dataDir="+dataDir);
+ log.info("Opening new SolrCore at " + getInstanceDir() + ",
dataDir="+dataDir);
if (schema==null) {
schema = new IndexSchema("schema.xml");
}
this.schema = schema;
- this.dataDir = dataDir;
- this.index_path = dataDir + "/" + "index";
+ File dataDirTemp = new File(dataDir);
+ this.dataDir = dataDirTemp;
+ this.index_path = new File(this.dataDir,"index");
this.maxWarmingSearchers = SolrConfig.config.getInt("query/
maxWarmingSearchers",Integer.MAX_VALUE);
@@ -421,7 +424,7 @@
// if this fails, we need to decrement onDeckSearchers again.
SolrIndexSearcher tmp;
try {
- tmp = new SolrIndexSearcher(schema, "main", index_path, true);
+ tmp = new SolrIndexSearcher(schema, "main", getIndexDir(), true);
} catch (Throwable th) {
synchronized(searcherLock) {
onDeckSearchers--;