From bf73201486212e651682a196212081fa0e0aa892 Mon Sep 17 00:00:00 2001 From: "Chris M. Hostetter" Date: Thu, 13 Sep 2012 23:22:13 +0000 Subject: [PATCH] SOLR-3569: Fixed debug output on distributed requests when there are no results found git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1384597 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 + .../handler/component/DebugComponent.java | 6 ++ .../org/apache/solr/util/SolrPluginUtils.java | 80 +++++++++++-------- 3 files changed, 54 insertions(+), 34 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 629534c595f..11d94b9867e 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -162,6 +162,8 @@ Bug Fixes not modify the result set or ranking of 'excluded' documents relative to not 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.java index 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(); + 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.java index 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 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 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 explainO - = getExplanations(query, otherResults, searcher, schema); - dbg.add("explainOther", explainStruct ? - explanationsToNamedLists(explainO) : - explanationsToStrings(explainO)); + NamedList explainO = getExplanations(query, otherResults, searcher, schema); + dbg.add("explainOther", explainStruct + ? explanationsToNamedLists(explainO) + : explanationsToStrings(explainO)); } } - - - return dbg; } public static NamedList explanationToNamedList(Explanation e) {