當前位置: 首頁>>代碼示例>>Java>>正文


Java CoreContainer.create方法代碼示例

本文整理匯總了Java中org.apache.solr.core.CoreContainer.create方法的典型用法代碼示例。如果您正苦於以下問題:Java CoreContainer.create方法的具體用法?Java CoreContainer.create怎麽用?Java CoreContainer.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.solr.core.CoreContainer的用法示例。


在下文中一共展示了CoreContainer.create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
 
開發者ID:bbende,項目名稱:solrj-custom-json-update,代碼行數:32,代碼來源:EmbeddedSolrServerFactory.java

示例2: 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);
}
 
開發者ID:bbende,項目名稱:solr-wikipedia,代碼行數:32,代碼來源:EmbeddedSolrServerFactory.java

示例3: createEmbeddedSolrServer

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
public static EmbeddedSolrServer createEmbeddedSolrServer(Path solrHomeDir, FileSystem fs, Path outputShardDir)
    throws IOException {

  if (solrHomeDir == null) {
    throw new IOException("Unable to find solr home setting");
  }
  LOG.info("Creating embedded Solr server with solrHomeDir: " + solrHomeDir + ", fs: " + fs + ", outputShardDir: " + outputShardDir);

  Path solrDataDir = new Path(outputShardDir, "data");

  String dataDirStr = solrDataDir.toUri().toString();

  SolrResourceLoader loader = new SolrResourceLoader(solrHomeDir.toString(), null, null);

  LOG.info(String
      .format(Locale.ENGLISH, 
          "Constructed instance information solr.home %s (%s), instance dir %s, conf dir %s, writing index to solr.data.dir %s, with permdir %s",
          solrHomeDir, solrHomeDir.toUri(), loader.getInstanceDir(),
          loader.getConfigDir(), dataDirStr, outputShardDir));

  // TODO: This is fragile and should be well documented
  System.setProperty("solr.directoryFactory", HdfsDirectoryFactory.class.getName()); 
  System.setProperty("solr.lock.type", "hdfs"); 
  System.setProperty("solr.hdfs.nrtcachingdirectory", "false");
  System.setProperty("solr.hdfs.blockcache.enabled", "false");
  System.setProperty("solr.autoCommit.maxTime", "600000");
  System.setProperty("solr.autoSoftCommit.maxTime", "-1");
  
  CoreContainer container = new CoreContainer(loader);
  container.load();
  
  Properties props = new Properties();
  props.setProperty(CoreDescriptor.CORE_DATADIR, dataDirStr);
  
  CoreDescriptor descr = new CoreDescriptor(container, "core1", solrHomeDir.toString(), props);
  
  SolrCore core = container.create(descr);
  
  if (!(core.getDirectoryFactory() instanceof HdfsDirectoryFactory)) {
    throw new UnsupportedOperationException(
        "Invalid configuration. Currently, the only DirectoryFactory supported is "
            + HdfsDirectoryFactory.class.getSimpleName());
  }

  EmbeddedSolrServer solr = new EmbeddedSolrServer(container, "core1");
  return solr;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:48,代碼來源:SolrRecordWriter.java

示例4: createEmbeddedSolrServer

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
public static EmbeddedSolrServer createEmbeddedSolrServer(Path solrHomeDir, FileSystem fs, Path outputShardDir)
    throws IOException {

  if (solrHomeDir == null) {
    throw new IOException("Unable to find solr home setting");
  }
  LOG.info("Creating embedded Solr server with solrHomeDir: " + solrHomeDir + ", fs: " + fs + ", outputShardDir: " + outputShardDir);

  Path solrDataDir = new Path(outputShardDir, "data");

  String dataDirStr = solrDataDir.toUri().toString();

  SolrResourceLoader loader = new SolrResourceLoader(solrHomeDir.toString(), null, null);

  LOG.info(String
      .format(Locale.ENGLISH, 
          "Constructed instance information solr.home %s (%s), instance dir %s, conf dir %s, writing index to solr.data.dir %s, with permdir %s",
          solrHomeDir, solrHomeDir.toUri(), loader.getInstanceDir(),
          loader.getConfigDir(), dataDirStr, outputShardDir));

  // TODO: This is fragile and should be well documented
  System.setProperty("solr.directoryFactory", HdfsDirectoryFactory.class.getName()); 
  System.setProperty("solr.lock.type", "hdfs"); 
  System.setProperty("solr.hdfs.nrtcachingdirectory", "false");
  System.setProperty("solr.hdfs.blockcache.enabled", "false");
  System.setProperty("solr.autoCommit.maxTime", "600000");
  System.setProperty("solr.autoSoftCommit.maxTime", "-1");
  
  CoreContainer container = new CoreContainer(loader);
  container.load();
  
  Properties props = new Properties();
  props.setProperty(CoreDescriptor.CORE_DATADIR, dataDirStr);
  
  CoreDescriptor descr = new CoreDescriptor(container, "core1", solrHomeDir.toString(), props);
  
  SolrCore core = container.create(descr);
  
  if (!(core.getDirectoryFactory() instanceof HdfsDirectoryFactory)) {
    throw new UnsupportedOperationException(
        "Invalid configuration. Currently, the only DirectoryFactory supported is "
            + HdfsDirectoryFactory.class.getSimpleName());
  }

  container.register(core, false);

  EmbeddedSolrServer solr = new EmbeddedSolrServer(container, "core1");
  return solr;
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:50,代碼來源:SolrRecordWriter.java


注:本文中的org.apache.solr.core.CoreContainer.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。