当前位置: 首页>>代码示例>>Java>>正文


Java IndexSchemaFactory类代码示例

本文整理汇总了Java中org.apache.solr.schema.IndexSchemaFactory的典型用法代码示例。如果您正苦于以下问题:Java IndexSchemaFactory类的具体用法?Java IndexSchemaFactory怎么用?Java IndexSchemaFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IndexSchemaFactory类属于org.apache.solr.schema包,在下文中一共展示了IndexSchemaFactory类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createIndexSchema

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
@Override
public IndexSchema createIndexSchema(final CoreDescriptor cd, final SolrConfig solrConfig) {
  final String resourceNameToBeUsed = IndexSchemaFactory.getResourceNameToBeUsed(cd.getSchemaName(), solrConfig);
  File schemaFile = new File(resourceNameToBeUsed);
  if (!schemaFile.isAbsolute()) {
    schemaFile = new File(solrConfig.getResourceLoader().getConfigDir(), schemaFile.getPath());
  }
  if (schemaFile.exists()) {
    try {
      return schemaCache.get(cacheName(schemaFile), new Callable<IndexSchema>() {
        @Override
        public IndexSchema call() throws Exception {
          logger.info("Creating new index schema for core {}", cd.getName());
          return IndexSchemaFactory.buildIndexSchema(cd.getSchemaName(), solrConfig);
        }
      });
    } catch (ExecutionException e) {
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
          "Error creating index schema for core " + cd.getName(), e);
    }
  }
  return IndexSchemaFactory.buildIndexSchema(cd.getSchemaName(), solrConfig);
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:ConfigSetService.java

示例2: testTieredMPSolrIndexConfigCreation

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
@Test
public void testTieredMPSolrIndexConfigCreation() throws Exception {
  SolrConfig solrConfig = new SolrConfig("solr" + File.separator
      + "collection1", "solrconfig-tieredmergepolicy.xml", null);
  SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null,
      null);
  assertNotNull(solrIndexConfig);
  IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", solrConfig);

  IndexWriterConfig iwc = solrIndexConfig.toIndexWriterConfig(indexSchema);

  assertNotNull("null mp", iwc.getMergePolicy());
  assertTrue("mp is not TMP", iwc.getMergePolicy() instanceof TieredMergePolicy);
  TieredMergePolicy mp = (TieredMergePolicy) iwc.getMergePolicy();
  assertEquals("mp.maxMergeAtOnceExplicit", 19, mp.getMaxMergeAtOnceExplicit());
  assertEquals("mp.segmentsPerTier",9,(int)mp.getSegmentsPerTier());

  assertNotNull("null ms", iwc.getMergeScheduler());
  assertTrue("ms is not CMS", iwc.getMergeScheduler() instanceof ConcurrentMergeScheduler);
  ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler)  iwc.getMergeScheduler();
  assertEquals("ms.maxMergeCount", 987, ms.getMaxMergeCount());
  assertEquals("ms.maxThreadCount", 42, ms.getMaxThreadCount());

}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:SolrIndexConfigTest.java

示例3: testDefaults

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
@Test
public void testDefaults() throws Exception {

  SolrConfig sc = new SolrConfig(new SolrResourceLoader("solr/collection1"), "solrconfig-defaults.xml", null);
  SolrIndexConfig sic = sc.indexConfig;
  assertEquals("default ramBufferSizeMB", 100.0D, sic.ramBufferSizeMB, 0.0D);
  assertEquals("default LockType", SolrIndexConfig.LOCK_TYPE_NATIVE, sic.lockType);
  assertEquals("default useCompoundFile", false, sic.useCompoundFile);

  IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", solrConfig);
  IndexWriterConfig iwc = sic.toIndexWriterConfig(indexSchema);

  assertNotNull("null mp", iwc.getMergePolicy());
  assertTrue("mp is not TMP", iwc.getMergePolicy() instanceof TieredMergePolicy);

  assertNotNull("null ms", iwc.getMergeScheduler());
  assertTrue("ms is not CMS", iwc.getMergeScheduler() instanceof ConcurrentMergeScheduler);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestConfig.java

示例4: TestHarness

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
/**
 * @param coreName to initialize
 * @param dataDirectory path for index data, will not be cleaned up
 * @param solrConfig solronfig instance
 * @param schemaFile schema filename
 */
   public TestHarness( String coreName,
                       String dataDirectory,
                       SolrConfig solrConfig,
                       String schemaFile) {
  this( coreName, dataDirectory, solrConfig, IndexSchemaFactory.buildIndexSchema(schemaFile, solrConfig));
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TestHarness.java

示例5: testFailingSolrIndexConfigCreation

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
@Test
public void testFailingSolrIndexConfigCreation() {
  try {
    SolrConfig solrConfig = new SolrConfig("bad-mp-solrconfig.xml");
    SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);
    IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", solrConfig);
    solrIndexConfig.toIndexWriterConfig(indexSchema);
    fail("a mergePolicy should have an empty constructor in order to be instantiated in Solr thus this should fail ");
  } catch (Exception e) {
    // it failed as expected
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:SolrIndexConfigTest.java

示例6: testCheckIntegrityAtMerge

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
@Test
public void testCheckIntegrityAtMerge() throws Exception {
  SolrConfig solrConfig = new SolrConfig("solr" + File.separator
      + "collection1", "solrconfig-indexconfig.xml", null);
  SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);
  assertNotNull(solrIndexConfig.checkIntegrityAtMerge);
  assertTrue(solrIndexConfig.checkIntegrityAtMerge);
  IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", solrConfig);
  IndexWriterConfig iwc = solrIndexConfig.toIndexWriterConfig(indexSchema);
  assertTrue(iwc.getCheckIntegrityAtMerge());
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:SolrIndexConfigTest.java

示例7: testMergedSegmentWarmerIndexConfigCreation

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
public void testMergedSegmentWarmerIndexConfigCreation() throws Exception {
  SolrConfig solrConfig = new SolrConfig("solr" + File.separator
      + "collection1", "solrconfig-warmer.xml", null);
  SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);
  assertNotNull(solrIndexConfig);
  assertNotNull(solrIndexConfig.mergedSegmentWarmerInfo);
  assertEquals(SimpleMergedSegmentWarmer.class.getName(),
      solrIndexConfig.mergedSegmentWarmerInfo.className);
  IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", solrConfig);
  IndexWriterConfig iwc = solrIndexConfig.toIndexWriterConfig(indexSchema);
  assertEquals(SimpleMergedSegmentWarmer.class, iwc.getMergedSegmentWarmer().getClass());
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:SolrIndexConfigTest.java

示例8: testTermVectorFields

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
@Test
public void testTermVectorFields() {
  
  IndexSchema ischema = IndexSchemaFactory.buildIndexSchema(getSchemaFile(), solrConfig);
  SchemaField f; // Solr field type
  IndexableField luf; // Lucene field

  f = ischema.getField("test_basictv");
  luf = f.createField("test", 0f);
  assertTrue(f.storeTermVector());
  assertTrue(luf.fieldType().storeTermVectors());

  f = ischema.getField("test_notv");
  luf = f.createField("test", 0f);
  assertTrue(!f.storeTermVector());
  assertTrue(!luf.fieldType().storeTermVectors());

  f = ischema.getField("test_postv");
  luf = f.createField("test", 0f);
  assertTrue(f.storeTermVector() && f.storeTermPositions());
  assertTrue(luf.fieldType().storeTermVectorPositions());

  f = ischema.getField("test_offtv");
  luf = f.createField("test", 0f);
  assertTrue(f.storeTermVector() && f.storeTermOffsets());
  assertTrue(luf.fieldType().storeTermVectorOffsets());

  f = ischema.getField("test_posofftv");
  luf = f.createField("test", 0f);
  assertTrue(f.storeTermVector() && f.storeTermPositions() && f.storeTermOffsets());
  assertTrue(luf.fieldType().storeTermVectorOffsets() && luf.fieldType().storeTermVectorPositions());

}
 
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:BasicFunctionalityTest.java

示例9: setUp

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
  super.setUp();
  schema = IndexSchemaFactory.buildIndexSchema(getSchemaFile(), solrConfig);
  clearIndex();
  assertU(commit());
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestReversedWildcardFilterFactory.java

示例10: reload

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
public SolrCore reload(SolrResourceLoader resourceLoader, SolrCore prev) throws IOException,
    ParserConfigurationException, SAXException {
  
  SolrConfig config = new SolrConfig(resourceLoader, getSolrConfig().getName(), null);
  
  IndexSchema schema = IndexSchemaFactory.buildIndexSchema(getLatestSchema().getResourceName(), config);
  
  solrCoreState.increfSolrCoreState();
  
  if (!getNewIndexDir().equals(getIndexDir())) {
    // the directory is changing, don't pass on state
    prev = null;
  }
  
  SolrCore core = new SolrCore(getName(), getDataDir(), config,
      schema, coreDescriptor, updateHandler, this.solrDelPolicy, prev);
  core.solrDelPolicy = this.solrDelPolicy;
  
  core.getUpdateHandler().getSolrCoreState().newIndexWriter(core, false);
  
  core.getSearcher(true, false, null, true);
  
  return core;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:25,代码来源:SolrCore.java

示例11: createFromLocal

import org.apache.solr.schema.IndexSchemaFactory; //导入依赖的package包/类
private SolrCore createFromLocal(String instanceDir, CoreDescriptor dcore) {
  SolrResourceLoader solrLoader = null;

  SolrConfig config = null;
  solrLoader = new SolrResourceLoader(instanceDir, loader.getClassLoader(), dcore.getSubstitutableProperties());
  try {
    config = new SolrConfig(solrLoader, dcore.getConfigName(), null);
  } catch (Exception e) {
    log.error("Failed to load file {}", new File(instanceDir, dcore.getConfigName()).getAbsolutePath());
    throw new SolrException(ErrorCode.SERVER_ERROR,
        "Could not load config file " + new File(instanceDir, dcore.getConfigName()).getAbsolutePath(),
        e);
  }

  IndexSchema schema = null;
  if (indexSchemaCache != null) {
    final String resourceNameToBeUsed = IndexSchemaFactory.getResourceNameToBeUsed(dcore.getSchemaName(), config);
    File schemaFile = new File(resourceNameToBeUsed);
    if (!schemaFile.isAbsolute()) {
      schemaFile = new File(solrLoader.getConfigDir(), schemaFile.getPath());
    }
    if (schemaFile.exists()) {
      String key = schemaFile.getAbsolutePath()
          + ":"
          + new SimpleDateFormat("yyyyMMddHHmmss", Locale.ROOT).format(new Date(
          schemaFile.lastModified()));
      schema = indexSchemaCache.get(key);
      if (schema == null) {
        log.info("creating new schema object for core: " + dcore.getName());
        schema = IndexSchemaFactory.buildIndexSchema(dcore.getSchemaName(), config);
        indexSchemaCache.put(key, schema);
      } else {
        log.info("re-using schema object for core: " + dcore.getName());
      }
    }
  }

  if (schema == null) {
    schema = IndexSchemaFactory.buildIndexSchema(dcore.getSchemaName(), config);
  }

  SolrCore core = new SolrCore(dcore.getName(), null, config, schema, dcore);

  if (core.getUpdateHandler().getUpdateLog() != null) {
    // always kick off recovery if we are in standalone mode.
    core.getUpdateHandler().getUpdateLog().recoverFromLog();
  }
  return core;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:50,代码来源:CoreContainer.java


注:本文中的org.apache.solr.schema.IndexSchemaFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。