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


Java SolrCore.execute方法代码示例

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


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

示例1: test404Locally

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
public void test404Locally() throws Exception {

    // we need to test that executing the handler directly does not 
    // throw an exception, just sets the exception on the response.
    initCore("solrconfig.xml", "schema.xml");
    try {
      // bypass TestHarness since it will throw any exception found in the
      // response.
      SolrCore core = h.getCore();
      SolrQueryResponse rsp = new SolrQueryResponse();
      core.execute(core.getRequestHandler("/admin/file"),
                   req("file", "does-not-exist-404.txt"), rsp);
      assertNotNull("no exception in response", rsp.getException());
      assertTrue("wrong type of exception: " + rsp.getException().getClass(),
                 rsp.getException() instanceof SolrException);
      assertEquals(404, ((SolrException)rsp.getException()).code());

    } catch (Exception e) {
      assertNull("Should not have caught an exception", e);
    }
  }
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:ShowFileRequestHandlerTest.java

示例2: testNotLazyField

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testNotLazyField() throws IOException {

  assertU(adoc("id", "7777",
               "title", "keyword",
               "test_hlt", mkstr(20000)));

  assertU(commit());
  SolrCore core = h.getCore();
 
  SolrQueryRequest req = req("q", "id:7777", "fl", "id,title,test_hlt");
  SolrQueryResponse rsp = new SolrQueryResponse();
  core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);

  DocList dl = ((ResultContext) rsp.getValues().get("response")).docs;
  Document d = req.getSearcher().doc(dl.iterator().nextDoc());
  // ensure field in fl is not lazy
  assertFalse( ((Field) d.getField("test_hlt")).getClass().getSimpleName().equals("LazyField"));
  assertFalse( ((Field) d.getField("title")).getClass().getSimpleName().equals("LazyField"));
  req.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:BasicFunctionalityTest.java

示例3: handlePing

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
protected void handlePing(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
{
  
  SolrParams params = req.getParams();
  SolrCore core = req.getCore();
  
  // Get the RequestHandler
  String qt = params.get( CommonParams.QT );//optional; you get the default otherwise
  SolrRequestHandler handler = core.getRequestHandler( qt );
  if( handler == null ) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, 
        "Unknown RequestHandler (qt): "+qt );
  }
  
  if( handler instanceof PingRequestHandler ) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, 
        "Cannot execute the PingRequestHandler recursively" );
  }
  
  // Execute the ping query and catch any possible exception
  Throwable ex = null;
  try {
    SolrQueryResponse pingrsp = new SolrQueryResponse();
    core.execute(handler, req, pingrsp );
    ex = pingrsp.getException();
  }
  catch( Exception e ) {
    ex = e;
  }
  
  // Send an error or an 'OK' message (response code will be 200)
  if( ex != null ) {
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, 
        "Ping query caused exception: "+ex.getMessage(), ex );
  }
  rsp.add( "status", "OK" );
}
 
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:PingRequestHandler.java


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