本文整理汇总了Java中org.apache.solr.request.SolrRequestHandler类的典型用法代码示例。如果您正苦于以下问题:Java SolrRequestHandler类的具体用法?Java SolrRequestHandler怎么用?Java SolrRequestHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolrRequestHandler类属于org.apache.solr.request包,在下文中一共展示了SolrRequestHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: request
import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
private SolrQueryRequest request(ModifiableSolrParams params) {
SolrCore core = h.getCore();
SolrRequestHandler handler = core.getRequestHandler(CENTROID_REQUEST_HANDLER);
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,代码来源:CentroidComponentTest.java
示例17: handleAdminRequest
import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
private void handleAdminRequest(HttpServletRequest req, ServletResponse response, SolrRequestHandler handler,
SolrQueryRequest solrReq) throws IOException {
SolrQueryResponse solrResp = new SolrQueryResponse();
SolrCore.preDecorateResponse(solrReq, solrResp);
handler.handleRequest(solrReq, solrResp);
SolrCore.postDecorateResponse(handler, solrReq, solrResp);
if (log.isInfoEnabled() && solrResp.getToLog().size() > 0) {
log.info(solrResp.getToLogAsString("[admin] "));
}
QueryResponseWriter respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get(solrReq.getParams().get(CommonParams.WT));
if (respWriter == null) respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get("standard");
writeResponse(solrResp, response, respWriter, solrReq, Method.getMethod(req.getMethod()));
}
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SolrDispatchFilter.java
示例18: execute
import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
protected void execute( HttpServletRequest req, SolrRequestHandler handler, SolrQueryRequest sreq, SolrQueryResponse rsp) {
// a custom filter could add more stuff to the request before passing it on.
// for example: sreq.getContext().put( "HttpServletRequest", req );
// used for logging query stats in SolrCore.execute()
sreq.getContext().put( "webapp", req.getContextPath() );
sreq.getCore().execute( handler, sreq, rsp );
}
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:SolrDispatchFilter.java
示例19: handlePing
import org.apache.solr.request.SolrRequestHandler; //导入依赖的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
示例20: getAll
import org.apache.solr.request.SolrRequestHandler; //导入依赖的package包/类
/**
* @return a Map of all registered handlers of the specified type.
*/
public <T extends SolrRequestHandler> Map<String,T> getAll(Class<T> clazz) {
Map<String,T> result = new HashMap<>(7);
for (Map.Entry<String,SolrRequestHandler> e : handlers.entrySet()) {
if(clazz.isInstance(e.getValue())) result.put(e.getKey(), clazz.cast(e.getValue()));
}
return result;
}
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:RequestHandlers.java
注:本文中的org.apache.solr.request.SolrRequestHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论