Revision 7590
Added by ben leinfelder almost 11 years ago
SolrIndex.java | ||
---|---|---|
27 | 27 |
package edu.ucsb.nceas.metacat.index; |
28 | 28 |
|
29 | 29 |
import java.io.ByteArrayInputStream; |
30 |
import java.io.File; |
|
30 | 31 |
import java.io.IOException; |
31 | 32 |
import java.io.InputStream; |
32 | 33 |
import java.util.ArrayList; |
... | ... | |
76 | 77 |
*/ |
77 | 78 |
public class SolrIndex { |
78 | 79 |
|
79 |
|
|
80 |
|
|
81 |
public static final String SOLRHOME = "solr.solr.home"; |
|
82 | 80 |
public static final String SOLRHOMEPROPERTYNAME = "solr.homeDir"; |
83 | 81 |
|
84 |
private static final String SOLRINDEXWEBCONTEXT = "metacat-index"; |
|
85 |
private static final String SOLRSERVERNAME = "metacat-core"; |
|
86 | 82 |
//private static final String DEFAULTSOLRHOMEPATH = "/Users/tao/Downloads/apache-solr-3.4.0/example/solr"; |
87 | 83 |
|
88 | 84 |
private List<IDocumentSubprocessor> subprocessors = null; |
... | ... | |
126 | 122 |
String solrHomeDir = null; |
127 | 123 |
solrHomeDir = Settings.getConfiguration().getString(SOLRHOMEPROPERTYNAME); |
128 | 124 |
log.info("========================= the solr home from the metacat.properties is "+solrHomeDir); |
129 |
if(solrHomeDir == null || solrHomeDir.trim().equals("")) { |
|
130 |
String deployDir = Settings.getConfiguration().getString("application.deployDir"); |
|
131 |
if(deployDir == null || deployDir.trim().equals("")) { |
|
132 |
solrHomeDir = SOLRINDEXWEBCONTEXT+"/WEB-INF/classes/solr-home"; |
|
133 |
} else { |
|
134 |
solrHomeDir = deployDir + "/" +SOLRINDEXWEBCONTEXT+"/WEB-INF/classes/solr-home"; |
|
135 |
} |
|
136 |
|
|
137 |
} |
|
138 |
log.info("==========================================final solr home is "+solrHomeDir); |
|
139 |
System.setProperty(SOLRHOME, solrHomeDir); |
|
140 |
CoreContainer.Initializer init = new CoreContainer.Initializer(); |
|
141 |
CoreContainer c = init.initialize(); |
|
125 |
File configFile = new File(solrHomeDir, "solr.xml"); |
|
126 |
CoreContainer c = new CoreContainer(solrHomeDir, configFile); |
|
127 |
c.load(solrHomeDir, configFile); |
|
142 | 128 |
solrServer = new EmbeddedSolrServer(c, "collection1"); |
143 | 129 |
} |
144 | 130 |
|
Also available in: Unified diff
simplify testing with embedded solr server locations -- no need to copy solr-home or set system properties. Still more to do (factory method) but this is getting cleaner.