org.apache.solr.handler.component.ShardRequest Java Examples
The following examples show how to use
org.apache.solr.handler.component.ShardRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnalyticsTestQParserPlugin.java From lucene-solr with Apache License 2.0 | 6 votes |
@SuppressWarnings({"unchecked"}) public void merge(ResponseBuilder rb, ShardRequest shardRequest) { int count = 0; @SuppressWarnings({"rawtypes"}) NamedList merged = new NamedList(); for(ShardResponse shardResponse : shardRequest.responses) { @SuppressWarnings({"rawtypes"}) NamedList response = shardResponse.getSolrResponse().getResponse(); @SuppressWarnings({"rawtypes"}) NamedList analytics = (NamedList)response.get("analytics"); Integer c = (Integer)analytics.get("mycount"); count += c.intValue(); } merged.add("mycount", count); rb.rsp.add("analytics", merged); }
Example #2
Source File: MtasSolrComponentStats.java From mtas with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void finishStage(ResponseBuilder rb) { if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) { for (ShardRequest sreq : rb.finished) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_STATS, false)) { for (ShardResponse shardResponse : sreq.responses) { NamedList<Object> response = shardResponse.getSolrResponse() .getResponse(); try { ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response .findRecursive("mtas", NAME); if (data != null) { MtasSolrResultUtil.decode(data); } } catch (ClassCastException e) { log.debug(e); // shouldnt happen } } } } } }
Example #3
Source File: MtasSolrComponentFacet.java From mtas with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void finishStage(ResponseBuilder rb) { if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) { for (ShardRequest sreq : rb.finished) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_FACET, false)) { for (ShardResponse shardResponse : sreq.responses) { NamedList<Object> response = shardResponse.getSolrResponse() .getResponse(); try { ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response .findRecursive("mtas", NAME); if (data != null) { MtasSolrResultUtil.decode(data); } } catch (ClassCastException e) { log.debug(e); // shouldn't happen } } } } } }
Example #4
Source File: MtasSolrComponentDocument.java From mtas with Apache License 2.0 | 6 votes |
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_DOCUMENT, false)) { if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) { // do nothing } else { Set<String> keys = MtasSolrResultUtil .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_DOCUMENT); sreq.params.remove(PARAM_MTAS_DOCUMENT); for (String key : keys) { sreq.params.remove( PARAM_MTAS_DOCUMENT + "." + key + "." + NAME_MTAS_DOCUMENT_FIELD); sreq.params.remove( PARAM_MTAS_DOCUMENT + "." + key + "." + NAME_MTAS_DOCUMENT_KEY); sreq.params.remove(PARAM_MTAS_DOCUMENT + "." + key + "." + NAME_MTAS_DOCUMENT_PREFIX); } } } }
Example #5
Source File: FacetModule.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { FacetComponentState facetState = getFacetComponentState(rb); if (facetState == null) return; if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) { sreq.purpose |= FacetModule.PURPOSE_GET_JSON_FACETS; sreq.params.set(FACET_INFO, "{}"); // The presence of FACET_INFO (_facet_) turns on json faceting } else { // turn off faceting on other requests /*** distributedProcess will need to use other requests for refinement sreq.params.remove("json.facet"); // this just saves space... the presence of FACET_INFO really control the faceting sreq.params.remove(FACET_INFO); **/ } }
Example #6
Source File: MtasSolrComponentPrefix.java From mtas with Apache License 2.0 | 6 votes |
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)) { if (sreq.params.getBool(PARAM_MTAS_PREFIX, false) && (sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) { // do nothing } else { // remove prefix for other requests Set<String> keys = MtasSolrResultUtil .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_PREFIX); sreq.params.remove(PARAM_MTAS_PREFIX); for (String key : keys) { sreq.params.remove( PARAM_MTAS_PREFIX + "." + key + "." + NAME_MTAS_PREFIX_FIELD); sreq.params.remove( PARAM_MTAS_PREFIX + "." + key + "." + NAME_MTAS_PREFIX_KEY); } } } }
Example #7
Source File: StoredFieldsShardResponseProcessor.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void process(ResponseBuilder rb, ShardRequest shardRequest) { boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0; ShardResponse srsp = shardRequest.responses.get(0); SolrDocumentList docs = (SolrDocumentList)srsp.getSolrResponse().getResponse().get("response"); String uniqueIdFieldName = rb.req.getSchema().getUniqueKeyField().getName(); for (SolrDocument doc : docs) { Object id = doc.getFieldValue(uniqueIdFieldName).toString(); ShardDoc shardDoc = rb.resultIds.get(id); FieldDoc fieldDoc = (FieldDoc) shardDoc; if (shardDoc != null) { if (returnScores && !Float.isNaN(fieldDoc.score)) { doc.setField("score", fieldDoc.score); } rb.retrievedDocuments.put(id, doc); } } }
Example #8
Source File: MtasSolrComponentPrefix.java From mtas with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void finishStage(ResponseBuilder rb) { if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) { for (ShardRequest sreq : rb.finished) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_PREFIX, false)) { for (ShardResponse shardResponse : sreq.responses) { NamedList<Object> response = shardResponse.getSolrResponse() .getResponse(); try { ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response .findRecursive("mtas", NAME); if (data != null) { MtasSolrResultUtil.decode(data); } } catch (ClassCastException e) { log.debug(e); // shouldnt happen } } } } } }
Example #9
Source File: OverseerCollectionMessageHandler.java From lucene-solr with Apache License 2.0 | 6 votes |
public void sendShardRequest(String nodeName, ModifiableSolrParams params, ShardHandler shardHandler, String adminPath, ZkStateReader zkStateReader) { if (asyncId != null) { String coreAdminAsyncId = asyncId + Math.abs(System.nanoTime()); params.set(ASYNC, coreAdminAsyncId); track(nodeName, coreAdminAsyncId); } ShardRequest sreq = new ShardRequest(); params.set("qt", adminPath); sreq.purpose = 1; String replica = zkStateReader.getBaseUrlForNodeName(nodeName); sreq.shards = new String[] {replica}; sreq.actualShards = sreq.shards; sreq.nodeName = nodeName; sreq.params = params; shardHandler.submit(sreq, replica, sreq.params); }
Example #10
Source File: OverseerNodePrioritizer.java From lucene-solr with Apache License 2.0 | 6 votes |
private void invokeOverseerOp(String electionNode, String op) { ModifiableSolrParams params = new ModifiableSolrParams(); ShardHandler shardHandler = ((HttpShardHandlerFactory)shardHandlerFactory).getShardHandler(httpClient); params.set(CoreAdminParams.ACTION, CoreAdminAction.OVERSEEROP.toString()); params.set("op", op); params.set("qt", adminPath); params.set("electionNode", electionNode); ShardRequest sreq = new ShardRequest(); sreq.purpose = 1; String replica = zkStateReader.getBaseUrlForNodeName(LeaderElector.getNodeName(electionNode)); sreq.shards = new String[]{replica}; sreq.actualShards = sreq.shards; sreq.params = params; shardHandler.submit(sreq, replica, sreq.params); shardHandler.takeCompletedOrError(); }
Example #11
Source File: PeerSync.java From lucene-solr with Apache License 2.0 | 6 votes |
private boolean requestUpdates(ShardResponse srsp, String versionsAndRanges, long totalUpdates) { String replica = srsp.getShardRequest().shards[0]; if (log.isInfoEnabled()) { log.info("{} Requesting updates from {} n={} versions={}", msg(), replica, totalUpdates, versionsAndRanges); } // reuse our original request object ShardRequest sreq = srsp.getShardRequest(); sreq.purpose = 0; sreq.params = new ModifiableSolrParams(); sreq.params.set("qt", "/get"); sreq.params.set(DISTRIB, false); sreq.params.set("getUpdates", versionsAndRanges); sreq.params.set("onlyIfActive", onlyIfActive); sreq.params.set("fingerprint",doFingerprint); sreq.responses.clear(); // needs to be zeroed for correct correlation to occur shardHandler.submit(sreq, sreq.shards[0], sreq.params); return true; }
Example #12
Source File: MtasSolrSearchComponent.java From mtas with Apache License 2.0 | 6 votes |
@Override public void handleResponses(ResponseBuilder rb, ShardRequest sreq) { // System.out // .println(System.nanoTime() + " - " + Thread.currentThread().getId() // + " - " + rb.req.getParams().getBool(ShardParams.IS_SHARD, false) // + " HANDLERESPONSES " + rb.stage + " " + rb.req.getParamString()); MtasSolrStatus solrStatus = Objects .requireNonNull((MtasSolrStatus) rb.req.getContext().get(MtasSolrStatus.class), "couldn't find status"); solrStatus.setStage(rb.stage); try { if (rb.req.getParams().getBool(PARAM_MTAS, false)) { // do nothing } } catch (ExitableDirectoryReader.ExitingReaderException e) { solrStatus.setError(e.getMessage()); } }
Example #13
Source File: NumFoundSearchComponent.java From BioSolr with Apache License 2.0 | 6 votes |
@Override public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { System.out.println("===== MODIFY REQUEST ====="); System.out.println("who=" + who); System.out.println("purpose=" + sreq.purpose); if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) > 0) { if (fieldListIncludes(rb, DJOIN_FIELD)) { Set<String> fl = new HashSet<>(getFieldList(sreq.params)); fl.add(SHARD_FIELD); sreq.params.set(CommonParams.FL, String.join(",", fl)); } // enable faceting on shards to get join ids sreq.params.set("facet", true); sreq.params.set("facet.field", joinField); } }
Example #14
Source File: RewriteFacetParametersComponentTest.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void rewriteShardedRequestParameters_mincountSetZero_shouldKeepMincountToZero() { ModifiableSolrParams fixed = new ModifiableSolrParams(); // The user has tried to set the mincount to zero. when(mockParams.getParameterNamesIterator()).thenReturn(asList("facet.mincount").iterator()); when(mockParams.get("facet.mincount")).thenReturn("0"); when(mockParams.get(ShardParams.SHARDS_PURPOSE)).thenReturn(String.valueOf(ShardRequest.PURPOSE_GET_FACETS)); Map<String, String> fieldMappings = new HashMap<>(); // Call the method under test. rewriteFacetParametersComponent.rewriteMincountFacetFieldOption(fixed, mockParams, "facet.mincount", fieldMappings, mockRequest); // Check that the mincount is set to 1 and the field name is converted to the format stored by Solr. String actualCount = fixed.get("facet.mincount"); assertEquals("Expected no fixed value", null, actualCount); }
Example #15
Source File: NumFoundSearchComponent.java From BioSolr with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void handleResponses(ResponseBuilder rb, ShardRequest req) { System.out.println("===== HANDLE RESPONSES ====="); System.out.println("purpose=" + req.purpose); System.out.println("Shards: " + (req.shards != null ? String.join(" ", req.shards) : "(null)")); if ((req.purpose & ShardRequest.PURPOSE_GET_FIELDS) > 0) { Map<String, Long> numFounds = (Map<String, Long>)rb.req.getContext().get(COMPONENT_NAME + "numFounds"); Set<Object> joinIds = (Set<Object>)rb.req.getContext().get(COMPONENT_NAME + "joinIds"); for (ShardResponse rsp : req.responses) { NamedList response = rsp.getSolrResponse().getResponse(); SolrDocumentList results = (SolrDocumentList)response.get("response"); numFounds.put(rsp.getShard(), results.getNumFound()); NamedList counts = (NamedList)response.get("facet_counts"); if (counts != null) { NamedList fields = (NamedList)counts.get("facet_fields"); NamedList values = (NamedList)fields.get(joinField); for (int i = 0; i < values.size(); ++i) { joinIds.add(values.getName(i)); } } } } }
Example #16
Source File: AsyncBuildSuggestComponent.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
/** Dispatch shard request in <code>STAGE_EXECUTE_QUERY</code> stage */ @Override public int distributedProcess(ResponseBuilder rb) { SolrParams params = rb.req.getParams(); LOG.debug("SuggestComponent distributedProcess with : " + params); if (rb.stage < ResponseBuilder.STAGE_EXECUTE_QUERY) return ResponseBuilder.STAGE_EXECUTE_QUERY; if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) { ShardRequest sreq = new ShardRequest(); sreq.purpose = ShardRequest.PURPOSE_GET_TOP_IDS; sreq.params = new ModifiableSolrParams(rb.req.getParams()); sreq.params.remove(ShardParams.SHARDS); rb.addRequest(this, sreq); return ResponseBuilder.STAGE_GET_FIELDS; } return ResponseBuilder.STAGE_DONE; }
Example #17
Source File: AbstractReSearcherComponent.java From solr-researcher with Apache License 2.0 | 5 votes |
@Override public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { if (!checkComponentShouldProcess(rb)) { return; } sreq.params.set(getComponentName(), "false"); }
Example #18
Source File: MockShardHandlerFactory.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public ShardHandler getShardHandler() { return new ShardHandler() { @Override public void prepDistributed(ResponseBuilder rb) {} @Override public void submit(ShardRequest sreq, String shard, ModifiableSolrParams params) {} @Override public ShardResponse takeCompletedIncludingErrors() { return null; } @Override public ShardResponse takeCompletedOrError() { return null; } @Override public void cancelAll() {} @Override public ShardHandlerFactory getShardHandlerFactory() { return MockShardHandlerFactory.this; } }; }
Example #19
Source File: MtasSolrComponentKwic.java From mtas with Apache License 2.0 | 5 votes |
public void finishStage(ResponseBuilder rb) { if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) { for (ShardRequest sreq : rb.finished) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_KWIC, false)) { // nothing to do } } } }
Example #20
Source File: MtasSolrComponentCollection.java From mtas with Apache License 2.0 | 5 votes |
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { // System.out.println( // "collection: " + System.nanoTime() + " - " + // Thread.currentThread().getId() // + " - " + rb.req.getParams().getBool("isShard", false) // + " MODIFYREQUEST " + rb.stage + " " + rb.req.getParamString()); if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_COLLECTION, false)) { if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) { // do nothing } else { // remove for other requests Set<String> keys = MtasSolrResultUtil .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_COLLECTION); sreq.params.remove(PARAM_MTAS_COLLECTION); for (String key : keys) { sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "." + NAME_MTAS_COLLECTION_ACTION); sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "." + NAME_MTAS_COLLECTION_ID); sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "." + NAME_MTAS_COLLECTION_FIELD); sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "." + NAME_MTAS_COLLECTION_POST); sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "." + NAME_MTAS_COLLECTION_KEY); sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "." + NAME_MTAS_COLLECTION_URL); sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "." + NAME_MTAS_COLLECTION_COLLECTION); } } } }
Example #21
Source File: OverseerCollectionMessageHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void processRebalanceLeaders(ClusterState clusterState, ZkNodeProps message, @SuppressWarnings({"rawtypes"})NamedList results) throws Exception { checkRequired(message, COLLECTION_PROP, SHARD_ID_PROP, CORE_NAME_PROP, ELECTION_NODE_PROP, CORE_NODE_NAME_PROP, BASE_URL_PROP, REJOIN_AT_HEAD_PROP); ModifiableSolrParams params = new ModifiableSolrParams(); params.set(COLLECTION_PROP, message.getStr(COLLECTION_PROP)); params.set(SHARD_ID_PROP, message.getStr(SHARD_ID_PROP)); params.set(REJOIN_AT_HEAD_PROP, message.getStr(REJOIN_AT_HEAD_PROP)); params.set(CoreAdminParams.ACTION, CoreAdminAction.REJOINLEADERELECTION.toString()); params.set(CORE_NAME_PROP, message.getStr(CORE_NAME_PROP)); params.set(CORE_NODE_NAME_PROP, message.getStr(CORE_NODE_NAME_PROP)); params.set(ELECTION_NODE_PROP, message.getStr(ELECTION_NODE_PROP)); params.set(BASE_URL_PROP, message.getStr(BASE_URL_PROP)); String baseUrl = message.getStr(BASE_URL_PROP); ShardRequest sreq = new ShardRequest(); sreq.nodeName = message.getStr(ZkStateReader.CORE_NAME_PROP); // yes, they must use same admin handler path everywhere... params.set("qt", adminPath); sreq.purpose = ShardRequest.PURPOSE_PRIVATE; sreq.shards = new String[] {baseUrl}; sreq.actualShards = sreq.shards; sreq.params = params; ShardHandler shardHandler = shardHandlerFactory.getShardHandler(overseer.getCoreContainer().getUpdateShardHandler().getDefaultHttpClient()); shardHandler.submit(sreq, baseUrl, sreq.params); }
Example #22
Source File: MtasSolrComponentGroup.java From mtas with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void finishStage(ResponseBuilder rb) { if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) { // decode finished results for (ShardRequest sreq : rb.finished) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_GROUP, false)) { for (ShardResponse shardResponse : sreq.responses) { NamedList<Object> response = shardResponse.getSolrResponse() .getResponse(); try { ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response .findRecursive("mtas", NAME); if (data != null) { MtasSolrResultUtil.decode(data); } } catch (ClassCastException e) { log.debug(e); // shouldn't happen } } } } } }
Example #23
Source File: MtasSolrComponentDocument.java From mtas with Apache License 2.0 | 5 votes |
public void finishStage(ResponseBuilder rb) { if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) { for (ShardRequest sreq : rb.finished) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_DOCUMENT, false)) { // nothing to do } } } }
Example #24
Source File: MtasSolrComponentKwic.java From mtas with Apache License 2.0 | 5 votes |
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)) { if (sreq.params.getBool(PARAM_MTAS_KWIC, false) && (sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) { // do nothing } else { Set<String> keys = MtasSolrResultUtil .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_KWIC); sreq.params.remove(PARAM_MTAS_KWIC); for (String key : keys) { sreq.params .remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_FIELD); sreq.params.remove( PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_TYPE); sreq.params.remove( PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_VALUE); sreq.params.remove( PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_PREFIX); sreq.params.remove( PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_IGNORE); sreq.params.remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_QUERY_MAXIMUM_IGNORE_LENGTH); sreq.params .remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_KEY); sreq.params.remove( PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_PREFIX); sreq.params.remove( PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_NUMBER); sreq.params .remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_LEFT); sreq.params .remove(PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_RIGHT); sreq.params.remove( PARAM_MTAS_KWIC + "." + key + "." + NAME_MTAS_KWIC_OUTPUT); } } } }
Example #25
Source File: ExactStatsCache.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override protected ShardRequest doRetrieveStatsRequest(ResponseBuilder rb) { // always request shard statistics ShardRequest sreq = new ShardRequest(); sreq.purpose = ShardRequest.PURPOSE_GET_TERM_STATS; sreq.params = new ModifiableSolrParams(rb.req.getParams()); // don't pass through any shards param sreq.params.remove(ShardParams.SHARDS); return sreq; }
Example #26
Source File: MtasSolrComponentVersion.java From mtas with Apache License 2.0 | 5 votes |
@Override public void finishStage(ResponseBuilder rb) { if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false)) { if (rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) { for (ShardRequest sreq : rb.finished) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_VERSION, false)) { for (ShardResponse shardResponse : sreq.responses) { NamedList<Object> solrShardResponse = shardResponse.getSolrResponse().getResponse(); try { SimpleOrderedMap<Object> data = (SimpleOrderedMap<Object>) solrShardResponse .findRecursive(MtasSolrSearchComponent.NAME, NAME); // create shardInfo SimpleOrderedMap<Object> dataShard = new SimpleOrderedMap<>(); dataShard.add(NAME_MTAS_VERSION_SHARD, shardResponse.getShard()); dataShard.add(NAME, data.clone()); List<SimpleOrderedMap> dataShards = new ArrayList<>(); dataShards.add(dataShard); // create main data data.clear(); data.addAll(getVersion()); // add shardInfo data.add(NAME_MTAS_VERSION_SHARDS, dataShards); } catch (ClassCastException | IOException e) { log.debug(e); // shouldn't happen } } } } } } }
Example #27
Source File: LocalStatsCache.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override protected ShardRequest doRetrieveStatsRequest(ResponseBuilder rb) { log.debug("## RSR {}", rb.req); // already incremented the stats - decrement it now statsCacheMetrics.retrieveStats.decrement(); return null; }
Example #28
Source File: FacetModule.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void handleResponses(ResponseBuilder rb, ShardRequest sreq) { FacetComponentState facetState = getFacetComponentState(rb); if (facetState == null) return; for (ShardResponse shardRsp : sreq.responses) { SolrResponse rsp = shardRsp.getSolrResponse(); NamedList<Object> top = rsp.getResponse(); if (top == null) continue; // shards.tolerant=true will cause this to happen on exceptions/errors Object facet = top.get("facets"); if (facet == null) { @SuppressWarnings("rawtypes") SimpleOrderedMap shardResponseHeader = (SimpleOrderedMap) rsp.getResponse().get("responseHeader"); if (Boolean.TRUE.equals(shardResponseHeader.getBooleanArg(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY))) { rb.rsp.getResponseHeader().asShallowMap().put(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY, Boolean.TRUE); } continue; } if (facetState.merger == null) { facetState.merger = facetState.facetRequest.createFacetMerger(facet); facetState.mcontext = new FacetMerger.Context(sreq.responses.size()); } if ((sreq.purpose & PURPOSE_REFINE_JSON_FACETS) != 0) { // System.err.println("REFINE FACET RESULT FROM SHARD = " + facet); // call merge again with a diff flag set on the context??? facetState.mcontext.root = facet; facetState.mcontext.setShard(shardRsp.getShard()); // TODO: roll newShard into setShard? facetState.merger.merge(facet, facetState.mcontext); return; } // System.err.println("MERGING FACET RESULT FROM SHARD = " + facet); facetState.mcontext.root = facet; facetState.mcontext.newShard(shardRsp.getShard()); facetState.merger.merge(facet, facetState.mcontext); } }
Example #29
Source File: FacetModule.java From lucene-solr with Apache License 2.0 | 5 votes |
private void clearFaceting(List<ShardRequest> outgoing) { // turn off faceting for requests not marked as being for faceting refinements for (ShardRequest sreq : outgoing) { if ((sreq.purpose & PURPOSE_REFINE_JSON_FACETS) != 0) continue; sreq.params.remove("json.facet"); // this just saves space... the presence of FACET_INFO is enough to control the faceting sreq.params.remove(FACET_INFO); } }
Example #30
Source File: MtasSolrComponentList.java From mtas with Apache License 2.0 | 5 votes |
public void finishStage(ResponseBuilder rb) { if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) { for (ShardRequest sreq : rb.finished) { if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false) && sreq.params.getBool(PARAM_MTAS_LIST, false)) { // nothing to do } } } }