container.load(); SolrCore core = container.create("core1", Paths.get(solrHomeDir.toString()), ImmutableMap.of(CoreDescriptor.CORE_DATADIR, dataDirStr), false);
@Override public void createReplacementCore(Vocabulary vocabulary) throws InitializationException { try { final String replacementCoreId = vocabulary.getIdentifier() + TEMP; final String absPath = this.environment.getPermanentDirectory().getAbsolutePath(); File tempDirectory = new File(absPath, SOLR + replacementCoreId); if (!tempDirectory.exists()) { Files.createDirectories(tempDirectory.toPath()); } CoreContainer container = this.coreContainer.getContainer(); File configOrigin = new File(absPath, SOLR + vocabulary.getIdentifier() + "/conf"); File configTemp = new File(absPath, SOLR + replacementCoreId + "/conf"); FileUtils.copyDirectory(configOrigin, configTemp); container.create(replacementCoreId, Collections.<String, String>emptyMap()); SolrClient core = new EmbeddedSolrServer(container, replacementCoreId); this.cores.put(replacementCoreId, core); } catch (IOException ex) { throw new InitializationException("Invalid Solr resource: " + ex.getMessage(), ex); } }
import java.io.*; import org.apache.solr.core.*; import org.apache.solr.client.solrj.*; import org.apache.solr.client.solrj.embedded.*; import org.bytedeco.javacpp.*; import org.bytedeco.javacpp.annotation.*; public class SolrTest { static SolrServer createServer(String coreName) throws Exception { CoreContainer coreContainer = new CoreContainer(); CoreDescriptor discriptor = new CoreDescriptor(coreContainer, coreName, new File("/some/path/", coreName).getAbsolutePath()); SolrCore solrCore = coreContainer.create(discriptor); coreContainer.register(solrCore, false); return new EmbeddedSolrServer(coreContainer, coreName); } static class Query extends FunctionPointer { public @Name("query") String call(String string) throws Exception { createServer(string); return string; } } }
container.load(); SolrCore core = container.create("core1", Paths.get(solrHomeDir.toString()), ImmutableMap.of(CoreDescriptor.CORE_DATADIR, dataDirStr), false);
container.load(); SolrCore core = container.create("core1", Paths.get(solrHomeDir.toString()), ImmutableMap.of(CoreDescriptor.CORE_DATADIR, dataDirStr), false);
CoreDescriptor coreDescriptor = new CoreDescriptor(coreContainer, coreId, solrCoreFolder.getAbsolutePath()); SolrCore core = coreContainer.create(coreDescriptor);
CoreDescriptor coreDescriptor = new CoreDescriptor(coreContainer, coreId, solrCoreFolder.getAbsolutePath()); SolrCore core = coreContainer.create(coreDescriptor);
/** * registers a {@link SolrCore} to the {@link #server} managed by this * instance. Will replace an already existing {@link SolrCore} with the * same name * @param coreName the name of the {@link SolrCore} to register * @param coreDir the directory for the Core. If <code>null</code> is parsed * {@link #managedSolrDir}/coreName is used as default. */ private void registerCore(String coreName, File coreDir) { if(coreName == null){ coreName = server.getDefaultCoreName(); } if(coreDir == null){ //use the coreName as default coreDir = new File(managedSolrDir,coreName); } if(!coreDir.isDirectory()){ throw new IllegalArgumentException("The Core Directory '"+ coreDir+" for the Core '"+coreName+"' does not exist or is not an directory"); } SolrCore core; CoreDescriptor coreDescriptor = new CoreDescriptor(server, coreName, coreDir.getAbsolutePath()); core = server.create(coreDescriptor); //this will also replace an existing core with the same name server.register(coreName, core, false); server.persist(); //store the new/updated SolrCore in the solr.xml } private IndexMetadata updateCore(IndexMetadata metadata, ArchiveInputStream ais){
/** * registers a {@link SolrCore} to the {@link #server} managed by this * instance. Will replace an already existing {@link SolrCore} with the * same name * @param coreName the name of the {@link SolrCore} to register * @param coreDir the directory for the Core. If <code>null</code> is parsed * {@link #managedSolrDir}/coreName is used as default. */ private void registerCore(String coreName, File coreDir) { if(coreName == null){ coreName = server.getDefaultCoreName(); } if(coreDir == null){ //use the coreName as default coreDir = new File(managedSolrDir,coreName); } if(!coreDir.isDirectory()){ throw new IllegalArgumentException("The Core Directory '"+ coreDir+" for the Core '"+coreName+"' does not exist or is not an directory"); } SolrCore core; CoreDescriptor coreDescriptor = new CoreDescriptor(server, coreName, coreDir.getAbsolutePath()); core = server.create(coreDescriptor); //this will also replace an existing core with the same name server.register(coreName, core, false); server.persist(); //store the new/updated SolrCore in the solr.xml } private IndexMetadata updateCore(IndexMetadata metadata, ArchiveInputStream ais){
SolrCore core = container.create(descr);
proxy.getCoreContainer().create(targetIndexName, targetIndexDir.toPath().toAbsolutePath(), emptyMap(), true); } catch (SolrException e) { if (e.code() == SolrException.ErrorCode.SERVER_ERROR.code) {
descr.setDataDir(dataDir); descr.setCoreProperties(props); core = container.create(descr); container.register(core, false); solr = new EmbeddedSolrServer(container, "core1");
container.create(coreIdentifier, Collections.<String, String>emptyMap());
/** * Recreates a SolrCore. * While the new core is loading, requests will continue to be dispatched to * and processed by the old core * * @param name the name of the SolrCore to reload * @throws ParserConfigurationException * @throws IOException * @throws SAXException */ public void reload(String name) throws ParserConfigurationException, IOException, SAXException { SolrCore core; synchronized(cores) { core = cores.get(name); } if (core == null) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "No such core: " + name ); SolrCore newCore = create(core.getCoreDescriptor()); // point all aliases to the reloaded core for (String alias : getCoreNames(core)) { if (!name.equals(alias)) { newCore.open(); register(alias, newCore, false); } } register(name, newCore, false); }
core = server.create(new CoreDescriptor(server, coreName, coreDir.getPath()));
core = server.create(new CoreDescriptor(server, coreName, coreDir.getPath()));
CoreDescriptor cd = new CoreDescriptor(cc, "dummy", solrServerRef.getIndex()); this.core = cc.create(cd); cc.register(core, false); server = new EmbeddedSolrServer(cc, "dummy");
CoreDescriptor cd = new CoreDescriptor(cc, "dummy", solrServerRef.getIndex()); this.core = cc.create(cd); cc.register(core, false); server = new EmbeddedSolrServer(cc, "dummy");
properties.put(CoreDescriptor.CORE_DATADIR, dataDir.getAbsolutePath()); properties.put(CoreDescriptor.CORE_CONFIGSET, "default"); core = m_coreContainer.create(index.getCoreName(), instanceDir.toPath(), properties); } catch (NullPointerException e) { if (core != null) {
SolrCore core = coreContainer.create(dcore); coreContainer.register(name, core, false); rsp.add("core", core.getName());