當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。