Example usage for org.apache.solr.core SolrCore getSchemaResource

List of usage examples for org.apache.solr.core SolrCore getSchemaResource

Introduction

In this page you can find the example usage for org.apache.solr.core SolrCore getSchemaResource.

Prototype

public String getSchemaResource() 

Source Link

Document

Gets the schema resource name used by this core instance.

Usage

From source file:com.searchbox.engine.solr.EmbeddedSolr.java

License:Apache License

@Override
public void register(Collection collection) {

    String coreInstanceDir = this.solrHome;

    Properties properties = new Properties();

    if (this.dataDir != null) {
        File dataDir = new File(this.dataDir);
        if (dataDir.exists()) {
            try {
                FileUtils.deleteDirectory(dataDir);
            } catch (IOException e) {
                LOGGER.error("Could not delete DataDir: " + dataDir);
            }// ww  w  .  jav a  2s . c om
        }
        properties.setProperty("dataDir", this.dataDir);
    } else {
        properties.setProperty("dataDir", coreInstanceDir + "/" + collection.getName() + "/data/");
    }

    CoreDescriptor dcore = new CoreDescriptor(coreContainer, collection.getName(), coreInstanceDir, properties);

    try {
        SolrCore core = coreContainer.create(dcore);
        coreContainer.register(core, false);

        LOGGER.info("Solr Core config: " + core.getConfigResource());
        LOGGER.info("Solr SchemaResource: " + core.getSchemaResource());
        LOGGER.info("Solr Data dir: " + core.getDataDir());
    } catch (Exception e) {
        LOGGER.warn(e.getMessage());
    }
}

From source file:org.opencommercesearch.EmbeddedSearchServer.java

License:Apache License

/**
 * Helper method to clone a core/*from  w  w w  .  j a v  a2  s  .  c o m*/
 */
private void cloneCore(SolrCore core, String collectionName, String coreName, String instanceDir, Locale locale)
        throws SolrServerException, IOException {
    if (isLoggingInfo()) {
        logInfo("Cloning core '" + core.getName() + "' into '" + coreName + "' using instance directory "
                + instanceDir);
    }

    CoreAdminRequest.Create create = new CoreAdminRequest.Create();

    create.setCoreName(coreName);
    create.setInstanceDir(instanceDir);
    create.setDataDir(coreName + "/data");
    create.setSchemaName(core.getSchemaResource());
    getSolrServer(collectionName, locale).request(create);

    CoreAdminRequest.MergeIndexes mergeIndexes = new CoreAdminRequest.MergeIndexes();
    mergeIndexes.setCoreName(coreName);
    mergeIndexes.setSrcCores(Arrays.asList(core.getName()));

    SolrServer server = getSolrServer(collectionName, locale);
    server.request(mergeIndexes);

}

From source file:org.xwiki.search.solr.internal.EmbeddedSolrInstanceInitializationTest.java

License:Open Source License

/**
 * TODO DOCUMENT ME!/* w w  w .  ja va2  s .c  o m*/
 * 
 * @param expected
 * @throws ComponentLookupException
 * @throws Exception
 */
private void getInstanceAndAssertHomeDirectory(String expected) throws ComponentLookupException, Exception {
    SolrInstance instance = mocker.getInstance(SolrInstance.class, "embedded");
    Assert.assertNotNull(instance);

    EmbeddedSolrInstance implementation = ((EmbeddedSolrInstance) instance);
    CoreContainer container = implementation.getContainer();

    if (expected == null) {
        expected = implementation.getDefaultHomeDirectory();
    }

    Assert.assertEquals(expected + File.separator, container.getSolrHome());
    Assert.assertEquals(1, container.getCores().size());
    SolrCore core = container.getCores().iterator().next();
    File coreBaseDirectory = new File(container.getSolrHome(), core.getName());
    File configDirectory = new File(coreBaseDirectory, DefaultSolrConfiguration.CONF_DIRECTORY);
    Assert.assertTrue(new File(configDirectory, core.getSchemaResource()).exists());
    Assert.assertTrue(new File(configDirectory, core.getConfigResource()).exists());
}