Apache Lucene open-source search software
SOLR-3569: Fixed debug output on distributed requests when there are no results found
Chris M. Hostetterbf7320148621
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 629534c595f..11d94b9867e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -162,6 +162,8 @@ Bug Fixesnot modify the result set or ranking of 'excluded' documents relative tonot using elevation at all. (Alexey Serba via hossman)+* SOLR-3569: Fixed debug output on distributed requests when there are no+ results found. (David Bowen via hossman)Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java b/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.javaindex 8f9623642ec..ff97632caf5 100644--- a/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java+++ b/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java@@ -145,7 +145,13 @@ public class DebugComponent extends SearchComponent}if (info == null) {+ // No responses were received from shards. Show local query info.info = new SimpleOrderedMap<Object>();+ SolrPluginUtils.doStandardQueryDebug(+ rb.req, rb.getQueryString(), rb.getQuery(), rb.isDebugQuery(), info);+ if (rb.isDebugQuery() && rb.getQparser() != null) {+ rb.getQparser().addDebugInfo(info);+ }}if (rb.isDebugResults()) {int idx = info.indexOf("explain",0);diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.javaindex 5053124f654..96aa5e23118 100644--- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java+++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java@@ -231,57 +231,69 @@ public class SolrPluginUtils {* @return The debug info* @throws java.io.IOException if there was an IO error*/- public static NamedList doStandardDebug(SolrQueryRequest req,- String userQuery,- Query query,- DocList results, boolean dbgQuery, boolean dbgResults)- throws IOException {-- NamedList dbg = null;-- dbg = new SimpleOrderedMap();-- SolrIndexSearcher searcher = req.getSearcher();- IndexSchema schema = req.getSchema();-- boolean explainStruct- = req.getParams().getBool(CommonParams.EXPLAIN_STRUCT, false);-+ public static NamedList doStandardDebug(+ SolrQueryRequest req,+ String userQuery,+ Query query,+ DocList results,+ boolean dbgQuery,+ boolean dbgResults)+ throws IOException+ {+ NamedList dbg = new SimpleOrderedMap();+ doStandardQueryDebug(req, userQuery, query, dbgQuery, dbg);+ doStandardResultsDebug(req, query, results, dbgResults, dbg);+ return dbg;+ }++ public static void doStandardQueryDebug(+ SolrQueryRequest req,+ String userQuery,+ Query query,+ boolean dbgQuery,+ NamedList dbg)+ {if (dbgQuery) {/* userQuery may have been pre-processed .. expose that */dbg.add("rawquerystring", req.getParams().get(CommonParams.Q));dbg.add("querystring", userQuery);- /* QueryParsing.toString isn't perfect, use it to see converted+ /* QueryParsing.toString isn't perfect, use it to see converted* values, use regular toString to see any attributes of the* underlying Query it may have missed.*/- dbg.add("parsedquery", QueryParsing.toString(query, schema));+ dbg.add("parsedquery", QueryParsing.toString(query, req.getSchema()));dbg.add("parsedquery_toString", query.toString());}-+ }++ public static void doStandardResultsDebug(+ SolrQueryRequest req,+ Query query,+ DocList results,+ boolean dbgResults,+ NamedList dbg) throws IOException+ {if (dbgResults) {- NamedList<Explanation> explain- = getExplanations(query, results, searcher, schema);- dbg.add("explain", explainStruct ?- explanationsToNamedLists(explain) :- explanationsToStrings(explain));+ SolrIndexSearcher searcher = req.getSearcher();+ IndexSchema schema = req.getSchema();+ boolean explainStruct = req.getParams().getBool(CommonParams.EXPLAIN_STRUCT, false);++ NamedList<Explanation> explain = getExplanations(query, results, searcher, schema);+ dbg.add("explain", explainStruct+ ? explanationsToNamedLists(explain)+ : explanationsToStrings(explain));String otherQueryS = req.getParams().get(CommonParams.EXPLAIN_OTHER);if (otherQueryS != null && otherQueryS.length() > 0) {- DocList otherResults = doSimpleQuery- (otherQueryS, req, 0, 10);+ DocList otherResults = doSimpleQuery(otherQueryS, req, 0, 10);dbg.add("otherQuery", otherQueryS);- NamedList<Explanation> explainO- = getExplanations(query, otherResults, searcher, schema);- dbg.add("explainOther", explainStruct ?- explanationsToNamedLists(explainO) :- explanationsToStrings(explainO));+ NamedList<Explanation> explainO = getExplanations(query, otherResults, searcher, schema);+ dbg.add("explainOther", explainStruct+ ? explanationsToNamedLists(explainO)+ : explanationsToStrings(explainO));}}--- return dbg;}public static NamedList<Object> explanationToNamedList(Explanation e) {