本文整理汇总了Java中org.apache.solr.core.CoreContainer.load方法的典型用法代码示例。如果您正苦于以下问题:Java CoreContainer.load方法的具体用法?Java CoreContainer.load怎么用?Java CoreContainer.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.core.CoreContainer
的用法示例。
在下文中一共展示了CoreContainer.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
/**
*
* @param solrHome
* path to directory where solr.xml lives
*
* @param coreName
* the name of the core to load
* @param dataDir
* the data dir for the core
*
* @return an EmbeddedSolrServer for the given core
*/
public static SolrClient create(String solrHome, String coreHome, String coreName, String dataDir) throws IOException {
File coreDataDir = new File(dataDir + "/" + coreName);
if (coreDataDir.exists()) {
FileUtils.deleteDirectory(coreDataDir);
}
CoreContainer coreContainer = new CoreContainer(solrHome);
coreContainer.load();
Properties props = new Properties();
props.setProperty("dataDir", dataDir + "/" + coreName);
CoreDescriptor descriptor = new CoreDescriptor(coreContainer, coreName,
new File(coreHome, coreName).getAbsolutePath(), props);
SolrCore solrCore = coreContainer.create(descriptor);
//coreContainer.register(solrCore, false);
return new EmbeddedSolrServer(coreContainer, coreName);
}
示例2: TestHarness
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
/**
* @param coreName to initialize
* @param dataDir path for index data, will not be cleaned up
* @param solrConfig solrconfig resource name
* @param indexSchema schema resource name
*/
public TestHarness(String coreName, String dataDir, String solrConfig, String indexSchema) {
try {
if (coreName == null)
coreName = ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME;
this.coreName = coreName;
SolrResourceLoader loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
ConfigSolr config = getTestHarnessConfig(loader, coreName, dataDir, solrConfig, indexSchema);
container = new CoreContainer(loader, config);
container.load();
updater = new UpdateRequestHandler();
updater.init( null );
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: setupContainer
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
private void setupContainer(int port, String shard) throws IOException,
ParserConfigurationException, SAXException {
File data = createTempDir();
System.setProperty("hostPort", Integer.toString(port));
System.setProperty("shard", shard);
System.setProperty("solr.data.dir", data.getAbsolutePath());
System.setProperty("solr.solr.home", TEST_HOME());
Set<Integer> ports = shardPorts.get(shard);
if (ports == null) {
ports = new HashSet<>();
shardPorts.put(shard, ports);
}
ports.add(port);
CoreContainer container = new CoreContainer();
container.load();
assertTrue("Container " + port + " has no cores!", container.getCores()
.size() > 0);
containerMap.put(port, container);
System.clearProperty("solr.solr.home");
System.clearProperty("hostPort");
}
示例4: create
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
/**
*
* @param solrHome
* path to directory where solr.xml lives
*
* @param coreName
* the name of the core to load
* @param dataDir
* the data dir for the core
*
* @return an EmbeddedSolrServer for the given core
*/
public static SolrServer create(String solrHome, String coreHome, String coreName, String dataDir) {
File coreDataDir = new File(dataDir + "/" + coreName);
if (coreDataDir.exists()) {
coreDataDir.delete();
}
CoreContainer coreContainer = new CoreContainer(solrHome);
coreContainer.load();
Properties props = new Properties();
props.setProperty("dataDir", dataDir + "/" + coreName);
CoreDescriptor descriptor = new CoreDescriptor(coreContainer, coreName,
new File(coreHome, coreName).getAbsolutePath(), props);
SolrCore solrCore = coreContainer.create(descriptor);
coreContainer.register(solrCore, false);
return new EmbeddedSolrServer(coreContainer, coreName);
}
示例5: setUp
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
coreContainer = new CoreContainer(solrPath);
coreContainer.load();
Assert.assertTrue(coreContainer.isLoaded(CORE_NAME));
server = new EmbeddedSolrServer(coreContainer, CORE_NAME);
Assert.assertNotNull(server);
solrHelper = new SolrHelper(server);
}
示例6: initSolrNode
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
protected void initSolrNode(String collection) {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
String solrHomePath = classLoader.getResource(SOLR_HOME).getPath();
solrNodesContainer = new CoreContainer(solrHomePath);
solrNodesContainer.load();
embeddedSolrServer = new EmbeddedSolrServer(solrNodesContainer, collection);
}
示例7: createCoreContainer
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
/**
* Override this to change CoreContainer initialization
* @return a CoreContainer to hold this server's cores
*/
protected CoreContainer createCoreContainer() {
SolrResourceLoader loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
ConfigSolr config = loadConfigSolr(loader);
CoreContainer cores = new CoreContainer(loader, config);
cores.load();
return cores;
}
示例8: init
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
private CoreContainer init() throws Exception {
File changed = new File(solrHomeDirectory, "changed");
copyMinConf(changed, "name=changed");
// Overlay with my local schema
schemaFile = new File(new File(changed, "conf"), "schema.xml");
FileUtils.writeStringToFile(schemaFile, withWhich, Charsets.UTF_8.toString());
String discoveryXml = "<solr></solr>";
File solrXml = new File(solrHomeDirectory, "solr.xml");
FileUtils.write(solrXml, discoveryXml, Charsets.UTF_8.toString());
final CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
cores.load();
return cores;
}
示例9: setUp
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
public void setUp() throws Exception {
super.setUp();
sequential.lock();
String solrString = "testdata/solr";
container = new CoreContainer(solrString);
container.load();
solrServer = new EmbeddedSolrServer(container, "sequence");
control = new SeqrController(solrServer);
solrServer.deleteByQuery("*:*");
control.loadJSONDir("testdata/data");
}
示例10: setUpController
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
private static void setUpController() throws SolrServerException, InterruptedException, IOException {
String solrString = "testdata/solr";
container = new CoreContainer(solrString);
container.load();
solrServer = new EmbeddedSolrServer(container, "sequence");
control = new SeqrController(solrServer);
}
示例11: create
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
@PostConstruct
public void create() {
//embedded options
Boolean embedded = Boolean.parseBoolean(env.get("solr.embedded", "false"));
String solrCore = env.get("solr.core", "mamute");
String solrHome = env.get("solr.home", "");
//remote options
String remoteUrl = env.get("solr.url", "");
if (embedded) {
LOGGER.info("Starting embedded Solr");
String home = solrHome;
if (isEmpty(home)) {
String locale = env.get("locale");
LOGGER.info("Using default home, with locale ["+locale+"]");
home = env.getResource("/solr/"+locale).getPath();
}
CoreContainer coreContainer = new CoreContainer(home);
coreContainer.load();
server = new EmbeddedSolrServer(coreContainer, solrCore);
} else if (isNotEmpty(remoteUrl)) {
LOGGER.info("Connecting to external Solr at [" + remoteUrl + "]");
server = new HttpSolrServer(remoteUrl);
} else {
LOGGER.warn("Solr config options not valid, not initting");
}
}
示例12: startup
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
@Before
public void startup() throws IOException, SolrServerException {
// start an embedded solr instance
coreContainer = new CoreContainer("solr");
coreContainer.load();
solr = new EmbeddedSolrServer(coreContainer, "heron");
solr.deleteByQuery("*:*");
solr.commit();
}
示例13: startup
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
@BeforeClass
public static void startup() throws Exception {
FileUtils.cleanDirectory(new File("solr/collection1/data/"));
FileUtils.cleanDirectory(new File("solr/collection1/suggestIndex/"));
FileUtils.cleanDirectory(new File("solr/heron/data/"));
// start an embedded solr instance
coreContainer = new CoreContainer("solr");
coreContainer.load();
}
示例14: getEmbeddedSolrServer
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
protected SolrServer getEmbeddedSolrServer(String solrCore) throws IOException, ParserConfigurationException, SAXException, SolrServerException {
String solrHomeDir = System.getProperty(SOLR_HOME);
File home = new File(solrHomeDir);
File f = new File(home, "solr.xml");
CoreContainer container = new CoreContainer();
container.load();
return new EmbeddedSolrServer(container, solrCore);
}
示例15: init
import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
@Override
public void init(Path path) throws DatabaseException {
super.init(path);
ResourceManager.copyResourcesToPath(this.getStoragePathSuffix(), this.path);
// Spin Solr up
logger.debug(String.valueOf(this.path));
cores = new CoreContainer(this.path.toString());
cores.load();
server = new EmbeddedSolrServer(cores, "variants");
}