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


Java SolrConfig类代码示例

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


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

示例1: SolrRequestParsers

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/**
 * Pass in an xml configuration.  A null configuration will enable
 * everything with maximum values.
 */
public SolrRequestParsers( SolrConfig globalConfig ) {
  final int multipartUploadLimitKB, formUploadLimitKB;
  if( globalConfig == null ) {
    multipartUploadLimitKB = formUploadLimitKB = Integer.MAX_VALUE; 
    enableRemoteStreams = true;
    handleSelect = true;
    addHttpRequestToContext = false;
  } else {
    multipartUploadLimitKB = globalConfig.getMultipartUploadLimitKB();
    
    formUploadLimitKB = globalConfig.getFormUploadLimitKB();
    
    enableRemoteStreams = globalConfig.isEnableRemoteStreams();

    // Let this filter take care of /select?xxx format
    handleSelect = globalConfig.isHandleSelect();
    
    addHttpRequestToContext = globalConfig.isAddHttpRequestToContext();
  }
  init(multipartUploadLimitKB, formUploadLimitKB);
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:SolrRequestParsers.java

示例2: setCacheControlHeader

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/**
 * Set the Cache-Control HTTP header (and Expires if needed)
 * based on the SolrConfig.
 * @param conf The config of the SolrCore handling this request
 * @param resp The servlet response object to modify
 * @param method The request method (GET, POST, ...) used by this request
 */
public static void setCacheControlHeader(final SolrConfig conf,
                                         final HttpServletResponse resp, final Method method) {
  // We do not emit HTTP header for POST and OTHER request types
  if (Method.POST==method || Method.OTHER==method) {
    return;
  }
  final String cc = conf.getHttpCachingConfig().getCacheControlHeader();
  if (null != cc) {
    resp.setHeader("Cache-Control", cc);
  }
  Long maxAge = conf.getHttpCachingConfig().getMaxAge();
  if (null != maxAge) {
    resp.setDateHeader("Expires", System.currentTimeMillis()
                       + (maxAge * 1000L));
  }

  return;
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:HttpCacheHeaderUtil.java

示例3: getTransformer

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/** Get Transformer from request context, or from TransformerProvider.
 *  This allows either getContentType(...) or write(...) to instantiate the Transformer,
 *  depending on which one is called first, then the other one reuses the same Transformer
 */
protected Transformer getTransformer(SolrQueryRequest request) throws IOException {
  final String xslt = request.getParams().get(CommonParams.TR,null);
  if(xslt==null) {
    throw new IOException("'" + CommonParams.TR + "' request parameter is required to use the XSLTResponseWriter");
  }
  // not the cleanest way to achieve this
  SolrConfig solrConfig = request.getCore().getSolrConfig();
  // no need to synchronize access to context, right? 
  // Nothing else happens with it at the same time
  final Map<Object,Object> ctx = request.getContext();
  Transformer result = (Transformer)ctx.get(CONTEXT_TRANSFORMER_KEY);
  if(result==null) {
    result = TransformerProvider.instance.getTransformer(solrConfig, xslt,xsltCacheLifetimeSeconds.intValue());
    result.setErrorListener(xmllog);
    ctx.put(CONTEXT_TRANSFORMER_KEY,result);
  }
  return result;
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:XSLTResponseWriter.java

示例4: SolrIndexConfig

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/**
 * Internal constructor for setting defaults based on Lucene Version
 */
@SuppressWarnings("deprecation")
private SolrIndexConfig(SolrConfig solrConfig) {
  luceneVersion = solrConfig.luceneMatchVersion;
  useCompoundFile = effectiveUseCompountFileSetting = false;
  maxBufferedDocs = -1;
  maxMergeDocs = -1;
  maxIndexingThreads = IndexWriterConfig.DEFAULT_MAX_THREAD_STATES;
  mergeFactor = -1;
  ramBufferSizeMB = 100;
  writeLockTimeout = -1;
  lockType = LOCK_TYPE_NATIVE;
  termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL;
  mergePolicyInfo = null;
  mergeSchedulerInfo = null;
  defaultMergePolicyClassName = TieredMergePolicy.class.getName();
  mergedSegmentWarmerInfo = null;
  checkIntegrityAtMerge = false;
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:SolrIndexConfig.java

示例5: getConfig

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
public static CacheConfig getConfig(SolrConfig solrConfig, Node node) {
  if (node==null) return null;
  CacheConfig config = new CacheConfig();
  config.nodeName = node.getNodeName();
  config.args = DOMUtil.toMap(node.getAttributes());
  String nameAttr = config.args.get("name");  // OPTIONAL
  if (nameAttr==null) {
    config.args.put("name",config.nodeName);
  }

  SolrResourceLoader loader = solrConfig.getResourceLoader();
  config.cacheImpl = config.args.get("class");
  config.regenImpl = config.args.get("regenerator");
  config.clazz = loader.findClass(config.cacheImpl, SolrCache.class);
  if (config.regenImpl != null) {
    config.regenerator = loader.newInstance(config.regenImpl, CacheRegenerator.class);
  }
  
  return config;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:CacheConfig.java

示例6: getTransformer

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/** Return a new Transformer, possibly created from our cached Templates object  
 * @throws IOException If there is a low-level I/O error.
 */ 
public synchronized Transformer getTransformer(SolrConfig solrConfig, String filename,int cacheLifetimeSeconds) throws IOException {
  // For now, the Templates are blindly reloaded once cacheExpires is over.
  // It'd be better to check the file modification time to reload only if needed.
  if(lastTemplates!=null && filename.equals(lastFilename) && System.currentTimeMillis() < cacheExpires) {
    if(log.isDebugEnabled()) {
      log.debug("Using cached Templates:" + filename);
    }
  } else {
    lastTemplates = getTemplates(solrConfig.getResourceLoader(), filename,cacheLifetimeSeconds);
  }
  
  Transformer result = null;
  
  try {
    result = lastTemplates.newTransformer();
  } catch(TransformerConfigurationException tce) {
    log.error(getClass().getName(), "getTransformer", tce);
    throw new IOException("newTransformer fails ( " + lastFilename + ")", tce);
  }
  
  return result;
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:TransformerProvider.java

示例7: create

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/** Returns an index schema created from a local resource */
public IndexSchema create(String resourceName, SolrConfig config) {
  SolrResourceLoader loader = config.getResourceLoader();
  InputStream schemaInputStream = null;

  if (null == resourceName) {
    resourceName = IndexSchema.DEFAULT_SCHEMA_FILE;
  }

  try {
    schemaInputStream = loader.openSchema(resourceName);
  } catch (Exception e) {
    final String msg = "Error loading schema resource " + resourceName;
    log.error(msg, e);
    throw new SolrException(ErrorCode.SERVER_ERROR, msg, e);
  }
  InputSource inputSource = new InputSource(schemaInputStream);
  inputSource.setSystemId(SystemIdResolver.createSystemIdFromResourceName(resourceName));
  IndexSchema schema = new IndexSchema(config, resourceName, inputSource);
  return schema;
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:IndexSchemaFactory.java

示例8: getResourceNameToBeUsed

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/** 
 * Returns the resource name that will be used: if the schema is managed, the resource
 * name will be drawn from the schema factory configuration in the given SolrConfig.
 * Otherwise, the given resourceName will be returned.
 * 
 * @param resourceName The name to use if the schema is not managed
 * @param config The SolrConfig from which to get the schema factory config
 * @return If the schema is managed, the resource name from the given SolrConfig,
 *         otherwise the given resourceName. 
 */
public static String getResourceNameToBeUsed(String resourceName, SolrConfig config) {
  PluginInfo info = config.getPluginInfo(IndexSchemaFactory.class.getName());
  final String nonManagedResourceName = null == resourceName ? IndexSchema.DEFAULT_SCHEMA_FILE : resourceName;
  if (null == info) {
    return nonManagedResourceName;
  }
  String managedSchemaResourceName
      = (String)info.initArgs.get(ManagedIndexSchemaFactory.MANAGED_SCHEMA_RESOURCE_NAME);
  if (null == managedSchemaResourceName) {
    managedSchemaResourceName = ManagedIndexSchemaFactory.DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME;
  }
  if ((new File(config.getResourceLoader().getConfigDir(), managedSchemaResourceName)).exists()) {
    return managedSchemaResourceName;
  }
  return nonManagedResourceName;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:IndexSchemaFactory.java

示例9: IndexSchema

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/**
 * Constructs a schema using the specified resource name and stream.
 * @see SolrResourceLoader#openSchema
 * By default, this follows the normal config path directory searching rules.
 * @see SolrResourceLoader#openResource
 */
public IndexSchema(SolrConfig solrConfig, String name, InputSource is) {
  assert null != solrConfig : "SolrConfig should never be null";
  assert null != name : "schema resource name should never be null";
  assert null != is : "schema InputSource should never be null";

  this.solrConfig = solrConfig;
  this.resourceName = name;
  loader = solrConfig.getResourceLoader();
  try {
    readSchema(is);
    loader.inform(loader);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:IndexSchema.java

示例10: testTieredMPSolrIndexConfigCreation

import org.apache.solr.core.SolrConfig; //导入依赖的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

示例11: startSolr

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/**
     * Start up an embedded Solr server.
     *
     * @param home The path to the Solr home directory
     * @return EmbeddedSolrServer: The instantiated server
     * @throws Exception if any errors occur
     */
    private EmbeddedSolrServer startSolr(String home) throws Exception {
        try {
            SolrConfig solrConfig = new SolrConfig(home, SOLR_CONFIG, null);
            IndexSchema schema = new IndexSchema(solrConfig, SOLR_SCHEMA, null);

            solrContainer = new CoreContainer(new SolrResourceLoader(
                    SolrResourceLoader.locateSolrHome()));
            CoreDescriptor descriptor = new CoreDescriptor(solrContainer, "",
                    solrConfig.getResourceLoader().getInstanceDir());
            descriptor.setConfigName(solrConfig.getResourceName());
            descriptor.setSchemaName(schema.getResourceName());

            solrCore = new SolrCore(null, solrConfig.getDataDir(),
                    solrConfig, schema, descriptor);
            solrContainer.register("cheese", solrCore, false);
//            CoreAdminRequest.create
            return new EmbeddedSolrServer(solrContainer, "cheese");
        } catch(Exception ex) {
            log.error("\nFailed to start Solr server\n");
            throw ex;
        }
    }
 
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:GeonamesIndexGenerator.java

示例12: SolrIndexConfig

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/**
 * Internal constructor for setting defaults based on Lucene Version
 */
@SuppressWarnings("deprecation")
private SolrIndexConfig(SolrConfig solrConfig) {
  luceneVersion = solrConfig.luceneMatchVersion;
  useCompoundFile = false;
  maxBufferedDocs = -1;
  maxMergeDocs = -1;
  maxIndexingThreads = IndexWriterConfig.DEFAULT_MAX_THREAD_STATES;
  mergeFactor = -1;
  ramBufferSizeMB = 100;
  writeLockTimeout = -1;
  lockType = LOCK_TYPE_NATIVE;
  termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL;
  mergePolicyInfo = null;
  mergeSchedulerInfo = null;
  defaultMergePolicyClassName = TieredMergePolicy.class.getName();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:SolrIndexConfig.java

示例13: getTransformer

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/** Return a new Transformer, possibly created from our cached Templates object  
 * @throws IOException If there is a low-level I/O error.
 */ 
public synchronized Transformer getTransformer(SolrConfig solrConfig, String filename,int cacheLifetimeSeconds) throws IOException {
  // For now, the Templates are blindly reloaded once cacheExpires is over.
  // It'd be better to check the file modification time to reload only if needed.
  if(lastTemplates!=null && filename.equals(lastFilename) && System.currentTimeMillis() < cacheExpires) {
    if(log.isDebugEnabled()) {
      log.debug("Using cached Templates:" + filename);
    }
  } else {
    lastTemplates = getTemplates(solrConfig.getResourceLoader(), filename,cacheLifetimeSeconds);
  }
  
  Transformer result = null;
  
  try {
    result = lastTemplates.newTransformer();
  } catch(TransformerConfigurationException tce) {
    log.error(getClass().getName(), "getTransformer", tce);
    final IOException ioe = new IOException("newTransformer fails ( " + lastFilename + ")");
    ioe.initCause(tce);
    throw ioe;
  }
  
  return result;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:28,代码来源:TransformerProvider.java

示例14: IndexSchema

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/**
 * Constructs a schema using the specified resource name and stream.
 * If the is stream is null, the resource loader will load the schema resource by name.
 * @see SolrResourceLoader#openSchema
 * By default, this follows the normal config path directory searching rules.
 * @see SolrResourceLoader#openResource
 */
public IndexSchema(SolrConfig solrConfig, String name, InputSource is) {
  this.solrConfig = solrConfig;
  if (name == null)
    name = DEFAULT_SCHEMA_FILE;
  this.resourceName = name;
  loader = solrConfig.getResourceLoader();
  try {
    if (is == null) {
      is = new InputSource(loader.openSchema(name));
      is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(name));
    }
    readSchema(is);
    loader.inform( loader );
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:IndexSchema.java

示例15: SolrIndexConfig

import org.apache.solr.core.SolrConfig; //导入依赖的package包/类
/**
 * Internal constructor for setting defaults based on Lucene Version
 */
@SuppressWarnings("deprecation")
private SolrIndexConfig(SolrConfig solrConfig) {
  luceneVersion = solrConfig.luceneMatchVersion;
  useCompoundFile = effectiveUseCompountFileSetting = false;
  maxBufferedDocs = -1;
  maxMergeDocs = -1;
  maxIndexingThreads = IndexWriterConfig.DEFAULT_MAX_THREAD_STATES;
  mergeFactor = -1;
  ramBufferSizeMB = 100;
  writeLockTimeout = -1;
  lockType = LOCK_TYPE_NATIVE;
  termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL;
  mergePolicyInfo = null;
  mergeSchedulerInfo = null;
  defaultMergePolicyClassName = TieredMergePolicy.class.getName();
  mergedSegmentWarmerInfo = null;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:SolrIndexConfig.java


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