本文整理汇总了Java中org.apache.solr.request.SolrRequestHandler.handleRequest方法的典型用法代码示例。如果您正苦于以下问题:Java SolrRequestHandler.handleRequest方法的具体用法?Java SolrRequestHandler.handleRequest怎么用?Java SolrRequestHandler.handleRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.request.SolrRequestHandler
的用法示例。
在下文中一共展示了SolrRequestHandler.handleRequest方法的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));
}
}
示例2: 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();}
}
}
示例3: 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();
}
示例4: 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());
}
示例5: 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
示例6: 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;
}
示例7: 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;
}
示例8: 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()));
}
示例9: handleRequest
import org.apache.solr.request.SolrRequestHandler; //导入方法依赖的package包/类
/**
* Wait for the first request before initializing the wrapped handler
*/
@Override
public void handleRequest(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrRequestHandler handler = _handler;
if (handler == null) {
handler = getWrappedHandler();
}
handler.handleRequest( req, rsp );
}
示例10: testCollateWithFilter
import org.apache.solr.request.SolrRequestHandler; //导入方法依赖的package包/类
@Test
public void testCollateWithFilter() throws Exception
{
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
assertTrue("speller is null and it shouldn't be", speller != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
params.add(SpellingParams.SPELLCHECK_BUILD, "true");
params.add(SpellingParams.SPELLCHECK_COUNT, "10");
params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10");
params.add(CommonParams.Q, "lowerfilt:(+fauth +home +loane)");
params.add(CommonParams.FQ, "NOT(id:1)");
//Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
//not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.add("responseHeader", new SimpleOrderedMap());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
handler.handleRequest(req, rsp);
req.close();
NamedList values = rsp.getValues();
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList suggestions = (NamedList) spellCheck.get("suggestions");
List<String> collations = suggestions.getAll("collation");
assertTrue(collations.size() > 0);
for(String collation : collations) {
assertTrue(!collation.equals("lowerfilt:(+faith +hope +loaves)"));
}
}
示例11: testCollateWithGrouping
import org.apache.solr.request.SolrRequestHandler; //导入方法依赖的package包/类
@Test
public void testCollateWithGrouping() throws Exception
{
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
assertTrue("speller is null and it shouldn't be", speller != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
params.add(SpellingParams.SPELLCHECK_BUILD, "true");
params.add(SpellingParams.SPELLCHECK_COUNT, "10");
params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "5");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1");
params.add(CommonParams.Q, "lowerfilt:(+fauth)");
params.add(GroupParams.GROUP, "true");
params.add(GroupParams.GROUP_FIELD, "id");
//Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
//not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.add("responseHeader", new SimpleOrderedMap());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
handler.handleRequest(req, rsp);
req.close();
NamedList values = rsp.getValues();
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList suggestions = (NamedList) spellCheck.get("suggestions");
List<String> collations = suggestions.getAll("collation");
assertTrue(collations.size() == 1);
}
示例12: testZeroTries
import org.apache.solr.request.SolrRequestHandler; //导入方法依赖的package包/类
@Test
public void testZeroTries() throws Exception
{
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
assertTrue("speller is null and it shouldn't be", speller != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10");
params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");
params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "0");
params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "2");
params.add(CommonParams.Q, "lowerfilt:(+fauth)");
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.add("responseHeader", new SimpleOrderedMap());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
handler.handleRequest(req, rsp);
req.close();
NamedList values = rsp.getValues();
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList suggestions = (NamedList) spellCheck.get("suggestions");
List<String> collations = suggestions.getAll("collation");
assertTrue(collations.size() == 2);
}
示例13: getState
import org.apache.solr.request.SolrRequestHandler; //导入方法依赖的package包/类
private SolrDocument getState(SolrQueryRequest request, String id)
{
ModifiableSolrParams newParams = new ModifiableSolrParams(request.getParams());
newParams.set("id", id);
request.setParams(newParams);
SolrRequestHandler handler = core.getRequestHandler(REQUEST_HANDLER_GET);
SolrQueryResponse rsp = new SolrQueryResponse();
handler.handleRequest(request, rsp);
@SuppressWarnings("rawtypes")
NamedList values = rsp.getValues();
SolrDocument state = (SolrDocument)values.get(RESPONSE_DEFAULT_ID);
return state;
}
示例14: getResponse
import org.apache.solr.request.SolrRequestHandler; //导入方法依赖的package包/类
/**
* @param requestHandler the handler that handles the request
* @param request the request object to put the params on
* @param params Solr parameters
* @return the response
*/
SolrQueryResponse getResponse(SolrRequestHandler requestHandler, SolrQueryRequest request, SolrParams params)
{
request.setParams(params);
log.info("Running query " + params.get("q"));
SolrQueryResponse solrRsp = new SolrQueryResponse();
requestHandler.handleRequest(request, solrRsp);
return solrRsp;
}
示例15: getTrackerInitialState
import org.apache.solr.request.SolrRequestHandler; //导入方法依赖的package包/类
@Override
public TrackerState getTrackerInitialState()
{
SolrQueryRequest request = null;
try
{
request = getLocalSolrQueryRequest();
TrackerState state = new TrackerState();
SolrRequestHandler handler = core.getRequestHandler(REQUEST_HANDLER_GET);
SolrQueryResponse rsp = new SolrQueryResponse();
ModifiableSolrParams newParams = new ModifiableSolrParams(request.getParams());
newParams.set("ids", "TRACKER!STATE!ACLTX,TRACKER!STATE!TX");
request.setParams(newParams);
handler.handleRequest(request, rsp);
@SuppressWarnings("rawtypes")
NamedList values = rsp.getValues();
SolrDocumentList response = (SolrDocumentList)values.get(RESPONSE_DEFAULT_IDS);
// We can find either or both docs here.
for(int i = 0; i < response.getNumFound(); i++)
{
SolrDocument current = response.get(i);
// ACLTX
if(current.getFieldValue(FIELD_S_ACLTXCOMMITTIME) != null)
{
if (state.getLastIndexedChangeSetCommitTime() == 0)
{
state.setLastIndexedChangeSetCommitTime(getFieldValueLong(current, FIELD_S_ACLTXCOMMITTIME));
}
if (state.getLastIndexedChangeSetId() == 0)
{
state.setLastIndexedChangeSetId(getFieldValueLong(current, FIELD_S_ACLTXID));
}
}
// TX
if(current.getFieldValue(FIELD_S_TXCOMMITTIME) != null)
{
if (state.getLastIndexedTxCommitTime() == 0)
{
state.setLastIndexedTxCommitTime(getFieldValueLong(current, FIELD_S_TXCOMMITTIME));
}
if (state.getLastIndexedTxId() == 0)
{
state.setLastIndexedTxId(getFieldValueLong(current, FIELD_S_TXID));
}
}
}
long startTime = System.currentTimeMillis();
state.setTimeToStopIndexing(startTime - lag);
state.setTimeBeforeWhichThereCanBeNoHoles(startTime - holeRetention);
long timeBeforeWhichThereCanBeNoTxHolesInIndex = state.getLastIndexedTxCommitTime() - holeRetention;
state.setLastGoodTxCommitTimeInIndex(timeBeforeWhichThereCanBeNoTxHolesInIndex > 0 ? timeBeforeWhichThereCanBeNoTxHolesInIndex : 0);
long timeBeforeWhichThereCanBeNoChangeSetHolesInIndex = state.getLastIndexedChangeSetCommitTime()
- holeRetention;
state.setLastGoodChangeSetCommitTimeInIndex(timeBeforeWhichThereCanBeNoChangeSetHolesInIndex > 0 ? timeBeforeWhichThereCanBeNoChangeSetHolesInIndex : 0);
return state;
}
finally
{
if(request != null) {request.close();}
}
}