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


Java CoreContainer.getCore方法代码示例

本文整理汇总了Java中org.apache.solr.core.CoreContainer.getCore方法的典型用法代码示例。如果您正苦于以下问题:Java CoreContainer.getCore方法的具体用法?Java CoreContainer.getCore怎么用?Java CoreContainer.getCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.core.CoreContainer的用法示例。


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

示例1: checkProps

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
private SolrCore checkProps(CoreContainer cores, String path,
    ZkNodeProps zkProps) {
  String corename;
  SolrCore core = null;
  if (cores.getZkController().getNodeName().equals(zkProps.getStr(ZkStateReader.NODE_NAME_PROP))) {
    corename = zkProps.getStr(ZkStateReader.CORE_NAME_PROP);
    core = cores.getCore(corename);
  }
  return core;
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:SolrDispatchFilter.java

示例2: testMergeIndexesCoreAdminHandler

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
@Test
public void testMergeIndexesCoreAdminHandler() throws Exception {
  final File workDir = createTempDir();

  final CoreContainer cores = h.getCoreContainer();

  final CoreAdminHandler admin = new CoreAdminHandler(cores);

  try (SolrCore core = cores.getCore("collection1")) {
    FailingDirectoryFactory dirFactory = (FailingDirectoryFactory)core.getDirectoryFactory();

    try {
      dirFactory.fail = true;
      ignoreException(FAILING_MSG);

      SolrQueryResponse resp = new SolrQueryResponse();
      admin.handleRequestBody
          (req(CoreAdminParams.ACTION,
              CoreAdminParams.CoreAdminAction.MERGEINDEXES.toString(),
              CoreAdminParams.CORE, "collection1",
              CoreAdminParams.INDEX_DIR, workDir.getAbsolutePath()),
              resp);
      fail("exception expected");
    } catch (FailingDirectoryFactory.FailingDirectoryFactoryException e) {
      // expected if error handling properly
    } finally {
      unIgnoreException(FAILING_MSG);
    }
    dirFactory.fail = false;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:CoreMergeIndexesAdminHandlerTest.java

示例3: testOptimizeDiffSchemas

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
@Test
public void testOptimizeDiffSchemas() throws Exception {
  // load up a core (why not put it on disk?)
  CoreContainer cc = init();
  try (SolrCore changed = cc.getCore("changed")) {

    // add some documents
    addDoc(changed, "id", "1", "which", "15", "text", "some stuff with which");
    addDoc(changed, "id", "2", "which", "15", "text", "some stuff with which");
    addDoc(changed, "id", "3", "which", "15", "text", "some stuff with which");
    addDoc(changed, "id", "4", "which", "15", "text", "some stuff with which");
    SolrQueryRequest req = new LocalSolrQueryRequest(changed, new NamedList<>());
    changed.getUpdateHandler().commit(new CommitUpdateCommand(req, false));

    // write the new schema out and make it current
    FileUtils.writeStringToFile(schemaFile, withoutWhich, Charsets.UTF_8.toString());

    IndexSchema iSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", changed.getSolrConfig());
    changed.setLatestSchema(iSchema);

    addDoc(changed, "id", "1", "text", "some stuff without which");
    addDoc(changed, "id", "5", "text", "some stuff without which");

    changed.getUpdateHandler().commit(new CommitUpdateCommand(req, false));
    changed.getUpdateHandler().commit(new CommitUpdateCommand(req, true));
  } finally {
    if (cc != null) cc.shutdown();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:ChangedSchemaMergeTest.java

示例4: getCoreStatus

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname, boolean isIndexInfoNeeded) throws IOException {
  NamedList<Object> info = new SimpleOrderedMap<Object>();
  SolrCore core = cores.getCore(cname);
  if (core != null) {
    try {
      info.add("name", core.getName());
      info.add("isDefaultCore", core.getName().equals(cores.getDefaultCoreName()));
      info.add("instanceDir", normalizePath(core.getResourceLoader().getInstanceDir()));
      info.add("dataDir", normalizePath(core.getDataDir()));
      info.add("config", core.getConfigResource());
      info.add("schema", core.getSchemaResource());
      info.add("startTime", new Date(core.getStartTime()));
      info.add("uptime", System.currentTimeMillis() - core.getStartTime());
      if (isIndexInfoNeeded) {
        RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
        try {
          SimpleOrderedMap<Object> indexInfo = LukeRequestHandler.getIndexInfo(searcher.get().getIndexReader());
          long size = getIndexSize(core);
          indexInfo.add("sizeInBytes", size);
          indexInfo.add("size", NumberUtils.readableSize(size));
          info.add("index", indexInfo);
        } finally {
          searcher.decref();
        }
      }
    } finally {
      core.close();
    }
  }
  return info;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:32,代码来源:CoreAdminHandler.java

示例5: getCoreStatus

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname, boolean isIndexInfoNeeded) throws IOException {
	NamedList<Object> info = new SimpleOrderedMap<Object>();
	SolrCore core = cores.getCore(cname);
	if(core != null) {
		try {
			info.add("name", core.getName());
			info.add("isDefaultCore", core.getName().equals(cores.getDefaultCoreName()));
			info.add("instanceDir", normalizePath(core.getResourceLoader().getInstanceDir()));
			info.add("dataDir", normalizePath(core.getDataDir()));
			info.add("config", core.getConfigResource());
			info.add("schema", core.getSchemaResource());
			info.add("startTime", new Date(core.getStartTime()));
			info.add("uptime", System.currentTimeMillis() - core.getStartTime());
			if(isIndexInfoNeeded) {
				RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
				try {
					SimpleOrderedMap<Object> indexInfo = LukeRequestHandler.getIndexInfo(searcher.get().getIndexReader());
					long size = getIndexSize(core);
					indexInfo.add("sizeInBytes", size);
					indexInfo.add("size", NumberUtils.readableSize(size));
					info.add("index", indexInfo);
				} finally {
					searcher.decref();
				}
			}
		} finally {
			core.close();
		}
	}
	return info;
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:32,代码来源:CoreAdminHandler.java

示例6: createParser

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
@Override
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
  return new QParser(qstr, localParams, params, req) {
    @Override
    public Query parse() throws SyntaxError {
      String fromField = getParam("from");
      String fromIndex = getParam("fromIndex");
      String toField = getParam("to");
      String v = localParams.get("v");
      Query fromQuery;
      long fromCoreOpenTime = 0;

      if (fromIndex != null && !fromIndex.equals(req.getCore().getCoreDescriptor().getName()) ) {
        CoreContainer container = req.getCore().getCoreDescriptor().getCoreContainer();

        final SolrCore fromCore = container.getCore(fromIndex);
        RefCounted<SolrIndexSearcher> fromHolder = null;

        if (fromCore == null) {
          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cross-core join: no such core " + fromIndex);
        }

        LocalSolrQueryRequest otherReq = new LocalSolrQueryRequest(fromCore, params);
        try {
          QParser parser = QParser.getParser(v, "lucene", otherReq);
          fromQuery = parser.getQuery();
          fromHolder = fromCore.getRegisteredSearcher();
          if (fromHolder != null) fromCoreOpenTime = fromHolder.get().getOpenTime();
        } finally {
          otherReq.close();
          fromCore.close();
          if (fromHolder != null) fromHolder.decref();
        }
      } else {
        QParser fromQueryParser = subQuery(v, null);
        fromQuery = fromQueryParser.getQuery();
      }

      JoinQuery jq = new JoinQuery(fromField, toField, fromIndex, fromQuery);
      jq.fromCoreOpenTime = fromCoreOpenTime;
      return jq;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:45,代码来源:JoinQParserPlugin.java

示例7: JoinQueryWeight

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
public JoinQueryWeight(SolrIndexSearcher searcher) {
  this.fromSearcher = searcher;
  SolrRequestInfo info = SolrRequestInfo.getRequestInfo();
  if (info != null) {
    rb = info.getResponseBuilder();
  }

  if (fromIndex == null) {
    this.fromSearcher = searcher;
  } else {
    if (info == null) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cross-core join must have SolrRequestInfo");
    }

    CoreContainer container = searcher.getCore().getCoreDescriptor().getCoreContainer();
    final SolrCore fromCore = container.getCore(fromIndex);

    if (fromCore == null) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cross-core join: no such core " + fromIndex);
    }

    if (info.getReq().getCore() == fromCore) {
      // if this is the same core, use the searcher passed in... otherwise we could be warming and
      // get an older searcher from the core.
      fromSearcher = searcher;
    } else {
      // This could block if there is a static warming query with a join in it, and if useColdSearcher is true.
      // Deadlock could result if two cores both had useColdSearcher and had joins that used eachother.
      // This would be very predictable though (should happen every time if misconfigured)
      fromRef = fromCore.getSearcher(false, true, null);

      // be careful not to do anything with this searcher that requires the thread local
      // SolrRequestInfo in a manner that requires the core in the request to match
      fromSearcher = fromRef.get();
    }

    if (fromRef != null) {
      final RefCounted<SolrIndexSearcher> ref = fromRef;
      info.addCloseHook(new Closeable() {
        @Override
        public void close() {
          ref.decref();
        }
      });
    }

    info.addCloseHook(new Closeable() {
      @Override
      public void close() {
        fromCore.close();
      }
    });

  }
  this.toSearcher = searcher;
}
 
开发者ID:europeana,项目名称:search,代码行数:57,代码来源:JoinQParserPlugin.java

示例8: getCoreStatus

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
/**
 * Returns the core status for a particular core.
 * @param cores - the enclosing core container
 * @param cname - the core to return
 * @param isIndexInfoNeeded - add what may be expensive index information. NOT returned if the core is not loaded
 * @return - a named list of key/value pairs from the core.
 * @throws IOException - LukeRequestHandler can throw an I/O exception
 */
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname, boolean isIndexInfoNeeded)  throws IOException {
  NamedList<Object> info = new SimpleOrderedMap<>();

  if (!cores.isLoaded(cname)) { // Lazily-loaded core, fill in what we can.
    // It would be a real mistake to load the cores just to get the status
    CoreDescriptor desc = cores.getUnloadedCoreDescriptor(cname);
    if (desc != null) {
      info.add("name", desc.getName());
      info.add("isDefaultCore", desc.getName().equals(cores.getDefaultCoreName()));
      info.add("instanceDir", desc.getInstanceDir());
      // None of the following are guaranteed to be present in a not-yet-loaded core.
      String tmp = desc.getDataDir();
      if (StringUtils.isNotBlank(tmp)) info.add("dataDir", tmp);
      tmp = desc.getConfigName();
      if (StringUtils.isNotBlank(tmp)) info.add("config", tmp);
      tmp = desc.getSchemaName();
      if (StringUtils.isNotBlank(tmp)) info.add("schema", tmp);
      info.add("isLoaded", "false");
    }
  } else {
    try (SolrCore core = cores.getCore(cname)) {
      if (core != null) {
        info.add("name", core.getName());
        info.add("isDefaultCore", core.getName().equals(cores.getDefaultCoreName()));
        info.add("instanceDir", normalizePath(core.getResourceLoader().getInstanceDir()));
        info.add("dataDir", normalizePath(core.getDataDir()));
        info.add("config", core.getConfigResource());
        info.add("schema", core.getSchemaResource());
        info.add("startTime", new Date(core.getStartTime()));
        info.add("uptime", System.currentTimeMillis() - core.getStartTime());
        if (isIndexInfoNeeded) {
          RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
          try {
            SimpleOrderedMap<Object> indexInfo = LukeRequestHandler.getIndexInfo(searcher.get().getIndexReader());
            long size = getIndexSize(core);
            indexInfo.add("sizeInBytes", size);
            indexInfo.add("size", NumberUtils.readableSize(size));
            info.add("index", indexInfo);
          } finally {
            searcher.decref();
          }
        }
      }
    }
  }
  return info;
}
 
开发者ID:europeana,项目名称:search,代码行数:56,代码来源:CoreAdminHandler.java

示例9: getCoreStatus

import org.apache.solr.core.CoreContainer; //导入方法依赖的package包/类
/**
 * Returns the core status for a particular core.
 * @param cores - the enclosing core container
 * @param cname - the core to return
 * @param isIndexInfoNeeded - add what may be expensive index information. NOT returned if the core is not loaded
 * @return - a named list of key/value pairs from the core.
 * @throws IOException - LukeRequestHandler can throw an I/O exception
 */
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname, boolean isIndexInfoNeeded)  throws IOException {
  NamedList<Object> info = new SimpleOrderedMap<Object>();

  if (!cores.isLoaded(cname)) { // Lazily-loaded core, fill in what we can.
    // It would be a real mistake to load the cores just to get the status
    CoreDescriptor desc = cores.getUnloadedCoreDescriptor(cname);
    if (desc != null) {
      info.add("name", desc.getName());
      info.add("isDefaultCore", desc.getName().equals(cores.getDefaultCoreName()));
      info.add("instanceDir", desc.getInstanceDir());
      // None of the following are guaranteed to be present in a not-yet-loaded core.
      String tmp = desc.getDataDir();
      if (StringUtils.isNotBlank(tmp)) info.add("dataDir", tmp);
      tmp = desc.getConfigName();
      if (StringUtils.isNotBlank(tmp)) info.add("config", tmp);
      tmp = desc.getSchemaName();
      if (StringUtils.isNotBlank(tmp)) info.add("schema", tmp);
      info.add("isLoaded", "false");
    }
  } else {
    SolrCore core = cores.getCore(cname);
    if (core != null) {
      try {
        info.add("name", core.getName());
        info.add("isDefaultCore", core.getName().equals(cores.getDefaultCoreName()));
        info.add("instanceDir", normalizePath(core.getResourceLoader().getInstanceDir()));
        info.add("dataDir", normalizePath(core.getDataDir()));
        info.add("config", core.getConfigResource());
        info.add("schema", core.getSchemaResource());
        info.add("startTime", new Date(core.getStartTime()));
        info.add("uptime", System.currentTimeMillis() - core.getStartTime());
        if (isIndexInfoNeeded) {
          RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
          try {
            SimpleOrderedMap<Object> indexInfo = LukeRequestHandler.getIndexInfo(searcher.get().getIndexReader());
            long size = getIndexSize(core);
            indexInfo.add("sizeInBytes", size);
            indexInfo.add("size", NumberUtils.readableSize(size));
            info.add("index", indexInfo);
          } finally {
            searcher.decref();
          }
        }
      } finally {
        core.close();
      }
    }
  }
  return info;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:59,代码来源:CoreAdminHandler.java


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