gus-asf commented on code in PR #2403: URL: https://github.com/apache/solr/pull/2403#discussion_r1566094054
########## solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java: ########## @@ -621,46 +684,72 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw rsp.addToLog(ThreadCpuTimer.CPU_TIME, totalShardCpuTime); } } + } - // SOLR-5550: still provide shards.info if requested even for a short circuited distrib request - if (!rb.isDistrib - && req.getParams().getBool(ShardParams.SHARDS_INFO, false) - && rb.shortCircuitedURL != null) { - NamedList<Object> shardInfo = new SimpleOrderedMap<>(); - SimpleOrderedMap<Object> nl = new SimpleOrderedMap<>(); - if (rsp.getException() != null) { - Throwable cause = rsp.getException(); - if (cause instanceof SolrServerException) { - cause = ((SolrServerException) cause).getRootCause(); - } else { - if (cause.getCause() != null) { - cause = cause.getCause(); - } - } - nl.add("error", cause.toString()); - if (!core.getCoreContainer().hideStackTrace()) { - StringWriter trace = new StringWriter(); - cause.printStackTrace(new PrintWriter(trace)); - nl.add("trace", trace.toString()); - } - } else if (rb.getResults() != null) { - nl.add("numFound", rb.getResults().docList.matches()); - nl.add( - "numFoundExact", - rb.getResults().docList.hitCountRelation() == TotalHits.Relation.EQUAL_TO); - nl.add("maxScore", rb.getResults().docList.maxScore()); - } - nl.add("shardAddress", rb.shortCircuitedURL); - nl.add("time", req.getRequestTimer().getTime()); // elapsed time of this request so far + private static String stageInEngilish(int nextStage) { + // This should probably be a enum, but that change should be its own ticket. + // public static int STAGE_START = 0; + // + // public static int STAGE_PARSE_QUERY = 1000; + // public static int STAGE_TOP_GROUPS = 1500; + // public static int STAGE_EXECUTE_QUERY = 2000; + // public static int STAGE_GET_FIELDS = 3000; + // public static int STAGE_DONE = Integer.MAX_VALUE; + switch (nextStage) { + case STAGE_START: + return "START"; + case STAGE_PARSE_QUERY: + return "PARSE_QUERY"; + case STAGE_TOP_GROUPS: + return "TOP_GROUPS"; + case STAGE_EXECUTE_QUERY: + return "EXECUTE_QUERY"; + case STAGE_GET_FIELDS: + return "GET_FIELDS"; + // nobody wants to think it was DONE and canceled after it completed... + case STAGE_DONE: + return "FINISHING"; + default: + throw new SolrException( + SolrException.ErrorCode.SERVER_ERROR, "Unrecognized stage:" + nextStage); + } + } - int pos = rb.shortCircuitedURL.indexOf("://"); - String shardInfoName = - pos != -1 ? rb.shortCircuitedURL.substring(pos + 3) : rb.shortCircuitedURL; - shardInfo.add(shardInfoName, nl); - rsp.getValues().add(ShardParams.SHARDS_INFO, shardInfo); + private static void shortCircuitedResults(SolrQueryRequest req, ResponseBuilder rb) { + + if (rb.rsp.getResponse() == null) { + rb.rsp.addResponse(new SolrDocumentList()); + + // If a cursorMark was passed, and we didn't progress, set + // the nextCursorMark to the same position + String cursorStr = rb.req.getParams().get(CursorMarkParams.CURSOR_MARK_PARAM); + if (null != cursorStr) { + rb.rsp.add(CursorMarkParams.CURSOR_MARK_NEXT, cursorStr); + } + } + if (rb.isDebug()) { + NamedList<Object> debug = new NamedList<>(); + debug.add("explain", new NamedList<>()); + rb.rsp.add("debug", debug); } } + private static boolean checkLimitsBefore( + SearchComponent c, + String when, + SolrQueryRequest req, + SolrQueryResponse resp, + List<SearchComponent> components) { + + return getQueryLimits(req, resp) + .maybeExitWithPartialResults( + () -> { Review Comment: oops, meant to do it the other way around so that the lambda is only evaluated if we're busting the limit. Will fix. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org