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


Java SolrRequestHandler类代码示例

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


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

示例1: execute

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {
  if (handler==null) {
    String msg = "Null Request Handler '" +
      req.getParams().get(CommonParams.QT) + "'";
    
    if (log.isWarnEnabled()) log.warn(logid + msg + ":" + req);
    
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, msg);
  }

  preDecorateResponse(req, rsp);

  // TODO: this doesn't seem to be working correctly and causes problems with the example server and distrib (for example /spell)
  // if (req.getParams().getBool(ShardParams.IS_SHARD,false) && !(handler instanceof SearchHandler))
  //   throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"isShard is only acceptable with search handlers");


  handler.handleRequest(req,rsp);
  postDecorateResponse(handler, req, rsp);

  if (log.isInfoEnabled() && rsp.getToLog().size() > 0) {
    log.info(rsp.getToLogAsString(logid));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:SolrCore.java

示例2: getWrappedHandler

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
public synchronized SolrRequestHandler getWrappedHandler()
{
  if( _handler == null ) {
    try {
      SolrRequestHandler handler = core.createRequestHandler(_className);
      handler.init( _args );

      if( handler instanceof SolrCoreAware ) {
        ((SolrCoreAware)handler).inform( core );
      }
      _handler = handler;
    }
    catch( Exception ex ) {
      throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "lazy loading error", ex );
    }
  }
  return _handler;
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:RequestHandlers.java

示例3: testClose

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
@Test
public void testClose() throws Exception {
  final CoreContainer cores = h.getCoreContainer();
  SolrCore core = cores.getCore("");

  ClosingRequestHandler handler1 = new ClosingRequestHandler();
  handler1.inform( core );

  String path = "/this/is A path /that won't be registered 2!!!!!!!!!!!";
  SolrRequestHandler old = core.registerRequestHandler( path, handler1 );
  assertNull( old ); // should not be anything...
  assertEquals( core.getRequestHandlers().get( path ), handler1 );
  core.close();
  cores.shutdown();
  assertTrue("Handler not closed", handler1.closed == true);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SolrCoreTest.java

示例4: testStatistics

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
@Test
public void testStatistics() {
  SolrCore core = h.getCore();
  SolrRequestHandler updateHandler = core.getRequestHandler("/update");
  SolrRequestHandler termHandler = core.getRequestHandler("/terms");

  assertU(adoc("id", "47",
      "text", "line up and fly directly at the enemy death cannons, clogging them with wreckage!"));
  assertU(commit());

  NamedList updateStats = updateHandler.getStatistics();
  NamedList termStats = termHandler.getStatistics();

  Double updateTime = (Double) updateStats.get("totalTime");
  Double termTime = (Double) termStats.get("totalTime");

  assertFalse("RequestHandlers should not share statistics!", updateTime.equals(termTime));
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:RequestHandlersTest.java

示例5: isInIndexImpl

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
private boolean isInIndexImpl(String ids) throws IOException
{
    SolrQueryRequest request = null;
    try
    {
        request = getLocalSolrQueryRequest();

        SolrRequestHandler handler = core.getRequestHandler(REQUEST_HANDLER_GET);
        SolrQueryResponse rsp = new SolrQueryResponse();

        ModifiableSolrParams newParams = new ModifiableSolrParams(request.getParams());
        newParams.set("ids", ids);
        request.setParams(newParams);

        handler.handleRequest(request, rsp);

        @SuppressWarnings("rawtypes")
        NamedList values = rsp.getValues();
        SolrDocumentList response = (SolrDocumentList)values.get(RESPONSE_DEFAULT_IDS);
        return response.getNumFound() > 0;
    }
    finally
    {
        if(request != null) {request.close();}
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:27,代码来源:SolrInformationServer.java

示例6: exists

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
/**
     * Returns whether or not a doc exists that satisfies the specified query
     * @param requestHandler the handler that handles the request
     * @param request the request object to put the query on
     * @param query the string that specifies the doc
     * @return <code>true</code> if the specified query returns a doc
     */
    boolean exists(SolrRequestHandler requestHandler, SolrQueryRequest request, String query)
    {
        ModifiableSolrParams params = new ModifiableSolrParams(request.getParams());
        // Sets 1 because this is effectively a boolean query to see if there exists a single match
        params.set("q", query).set("fl", "id").set("rows", "1");
        ResultContext rc = this.getResultContext(requestHandler, request, params);

        if (rc != null)
        {
// TODO Should we use rc.docs.matches() instead?
            if (rc.docs != null) { return rc.docs.iterator().hasNext(); }
        }

        return false;
    }
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:23,代码来源:Cloud.java

示例7: setUp

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
/**
 * Setup fixture for this test case.
 */
@Before
public void setUp() {
	cut = spy(new Sparql11SearchHandler() {
		@Override
		SolrRequestHandler requestHandler(final SolrQueryRequest request, final String name) {
			return mock(SolrRequestHandler.class);
		}
	});
	
	request = mock(SolrQueryRequest.class);
	response = mock(SolrQueryResponse.class);
	httpRequest = mock(HttpServletRequest.class);
	
	final Map<Object, Object> context = new HashMap<Object, Object>();
	context.put(Names.HTTP_REQUEST_KEY, httpRequest);
	when(request.getContext()).thenReturn(context);
}
 
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:21,代码来源:Sparql11SearchHandlerTestCase.java

示例8: execute

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {
  if (handler==null) {
    String msg = "Null Request Handler '" +
      req.getParams().get(CommonParams.QT) + "'";
    
    if (log.isWarnEnabled()) log.warn(logid + msg + ":" + req);
    
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, msg);
  }

  preDecorateResponse(req, rsp);

  // TODO: this doesn't seem to be working correctly and causes problems with the example server and distrib (for example /spell)
  // if (req.getParams().getBool(ShardParams.IS_SHARD,false) && !(handler instanceof SearchHandler))
  //   throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"isShard is only acceptable with search handlers");

  handler.handleRequest(req,rsp);

  postDecorateResponse(handler, req, rsp);

  if (log.isInfoEnabled() && rsp.getToLog().size() > 0) {
    log.info(rsp.getToLogAsString(logid));
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:SolrCore.java

示例9: execute

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {
	if(handler == null) {
		String msg = "Null Request Handler '" + req.getParams().get(CommonParams.QT) + "'";

		if(log.isWarnEnabled())
			log.warn(logid + msg + ":" + req);

		throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, msg);
	}

	preDecorateResponse(req, rsp);

	// TODO: this doesn't seem to be working correctly and causes problems with the example server and distrib (for example /spell)
	// if (req.getParams().getBool(ShardParams.IS_SHARD,false) && !(handler instanceof SearchHandler))
	//   throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"isShard is only acceptable with search handlers");

	handler.handleRequest(req, rsp);

	postDecorateResponse(handler, req, rsp);

	if(log.isInfoEnabled() && rsp.getToLog().size() > 0) {
		log.info(rsp.getToLogAsString(logid));
	}
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:25,代码来源:SolrCore.java

示例10: test

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
protected NamedList test(ModifiableSolrParams params, String componentName) {
  SolrCore core = h.getCore();

  SearchComponent sc = core.getSearchComponent(componentName);
  assertTrue("XJoinSearchComponent not found in solrconfig", sc != null);
    
  QParserPlugin qp = core.getQueryPlugin("xjoin");
  assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null);
  
  params.add("q", "*:*");
  params.add("fq", "{!xjoin}" + componentName);

  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.add("responseHeader", new SimpleOrderedMap<>());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

  SolrRequestHandler handler = core.getRequestHandler("standard");
  handler.handleRequest(req, rsp);
  req.close();
  assertNull(rsp.getException());
    
  return rsp.getValues();
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:25,代码来源:AbstractXJoinTestCase.java

示例11: testBadRequest_missingLocalParams

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
@Test
public void testBadRequest_missingLocalParams() {
	SolrCore core = h.getCore();
	
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q", "*:*");
	params.add("facet", "true");
	params.add("facet.tree", "true");
	params.add("facet.tree.field", "node_id");
	
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap<>());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

    SolrRequestHandler handler = core.getRequestHandler(requestHandler);
    handler.handleRequest(req, rsp);
    req.close();
      
    assertNotNull(rsp.getException());
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:21,代码来源:SimpleTreeFacetComponentTest.java

示例12: testBadRequest_missingChildField

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
@Test
public void testBadRequest_missingChildField() {
	SolrCore core = h.getCore();
	
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q", "*:*");
	params.add("facet", "true");
	params.add("facet.tree", "true");
	params.add("facet.tree.field", "{!ftree childField=blah}node_id");
	
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap<>());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

    SolrRequestHandler handler = core.getRequestHandler(requestHandler);
    handler.handleRequest(req, rsp);
    req.close();
      
    assertNotNull(rsp.getException());
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:21,代码来源:SimpleTreeFacetComponentTest.java

示例13: executeQuery

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
/**
 * Executes the given handler (query) logic.
 * @param request the current {@link SolrQueryRequest}.
 * @param response the current {@link SolrQueryResponse}.
 * @param params the request parameters.
 * @param handler the executor handler.
 * @return the query response, that is, the result of the handler's query execution.
 */
@SuppressWarnings("unchecked")
NamedList<Object> executeQuery(
		final SolrQueryRequest request, 
		final SolrQueryResponse response, 
		final SolrParams params, 
		final SolrRequestHandler handler) {
	try(final SolrQueryRequest scopedRequest = newFrom(request, params)) {
		final SolrQueryResponse scopedResponse = newFrom(response);
		handler.handleRequest(
				scopedRequest, 
				scopedResponse); 
		return scopedResponse.getValues();	
	}
}
 
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:23,代码来源:InvisibleQueriesRequestHandler.java

示例14: executeQuery

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
@Test
public void executeQuery() {
	final SolrRequestHandler handler = mock(SolrRequestHandler.class);
	
	final NamedList<?> result = cut.executeQuery(qrequest, qresponse, params, handler);
	
	verify(handler).handleRequest(any(SolrQueryRequest.class), any(SolrQueryResponse.class));
	assertEquals(1, result.size());
}
 
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:10,代码来源:FacadeRequestHandlerTestCase.java

示例15: request

import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
private SolrQueryRequest request(ModifiableSolrParams params, String handlerName) {
  SolrCore core = h.getCore();
  SolrRequestHandler handler = core.getRequestHandler(handlerName);

  SolrQueryResponse rsp = new SolrQueryResponse();
  NamedList<Object> list = new NamedList<Object>();
  list.add("responseHeader", new SimpleOrderedMap<Object>());
  rsp.setAllValues(list);
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  return req;
}
 
开发者ID:sematext,项目名称:query-segmenter,代码行数:13,代码来源:QuerySegmenterComponentTest.java


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