mirror of https://github.com/apache/lucene.git
SOLR-1915 followup - based on feedback in the issue i've renamed the param for controlling wether the score explanations sre structured, undeprecated the existing toString() format, and changed it back to being the default
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@950667 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
00cdc313e1
commit
9d56e2d62e
|
@ -66,15 +66,6 @@ Upgrading from Solr 1.4
|
|||
(since it has never worked properly). Solr will now warn you if
|
||||
you attempt to set this configuration option at all. (see SOLR-1846)
|
||||
|
||||
* The format of score explanations in the debug section has been
|
||||
changed to represent the structure of the Explanation object in the
|
||||
approprate format based on the ResponseWriter. In the unlikely
|
||||
event that client code was previously depending on the previous
|
||||
"white space indented plaintext string" format, a
|
||||
"debug.explain.stringFormat=true" param can be added to the request
|
||||
to force the old behavior -- but support for this will be removed in
|
||||
the next release.
|
||||
|
||||
Detailed Change List
|
||||
----------------------
|
||||
|
||||
|
@ -171,7 +162,10 @@ New Features
|
|||
|
||||
* SOLR-1923: PhoneticFilterFactory now has support for the
|
||||
Caverphone algorithm. (rmuir)
|
||||
|
||||
|
||||
* SOLR-1915: DebugComponent now supports using a NamedList to model
|
||||
Explanation objects in it's responses instead of
|
||||
Explanation.toString (hossman)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
@ -398,9 +392,6 @@ Other Changes
|
|||
* SOLR-1846: Eliminate support for the abortOnConfigurationError
|
||||
option. It has never worked very well, and in recent versions of
|
||||
Solr hasn't worked at all. (hossman)
|
||||
|
||||
* SOLR-1915: DebugComponent now uses a NamedList to model Explanation
|
||||
objects in it's responses instead of Explanation.toString (hossman)
|
||||
|
||||
Build
|
||||
----------------------
|
||||
|
|
|
@ -62,11 +62,10 @@ public interface CommonParams {
|
|||
public static final String DEBUG_QUERY = "debugQuery";
|
||||
|
||||
/**
|
||||
* whether score explanations should be in legacy plain text format
|
||||
* @deprecated The plain text version will be removed in a future version
|
||||
* boolean indicating whether score explanations should structured (true),
|
||||
* or plain text (false)
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String EXPLAIN_AS_STRING = "debug.explain.stringFormat";
|
||||
public static final String EXPLAIN_STRUCT = "debug.explain.structured";
|
||||
|
||||
/** another query to explain against */
|
||||
public static final String EXPLAIN_OTHER = "explainOther";
|
||||
|
|
|
@ -399,9 +399,9 @@ public class SolrPluginUtils {
|
|||
SolrIndexSearcher searcher = req.getSearcher();
|
||||
IndexSchema schema = req.getSchema();
|
||||
|
||||
boolean legacyExplainStyle
|
||||
= req.getParams().getBool(CommonParams.EXPLAIN_AS_STRING,false);
|
||||
|
||||
boolean explainStruct
|
||||
= req.getParams().getBool(CommonParams.EXPLAIN_STRUCT,false);
|
||||
|
||||
/* userQuery may have been pre-processes .. expose that */
|
||||
dbg.add("rawquerystring", req.getParams().get(CommonParams.Q));
|
||||
dbg.add("querystring", userQuery);
|
||||
|
@ -413,18 +413,22 @@ public class SolrPluginUtils {
|
|||
dbg.add("parsedquery",QueryParsing.toString(query, schema));
|
||||
dbg.add("parsedquery_toString", query.toString());
|
||||
|
||||
dbg.add("explain", legacyExplainStyle ?
|
||||
getExplainList(query, results, searcher, schema) :
|
||||
explanationsToNamedLists(getExplanations(query, results, searcher, schema)));
|
||||
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.getSearcher(), req.getSchema(),0,10);
|
||||
dbg.add("otherQuery",otherQueryS);
|
||||
dbg.add("explainOther", legacyExplainStyle ?
|
||||
getExplainList(query, otherResults, searcher, schema) :
|
||||
explanationsToNamedLists(getExplanations(query, otherResults, searcher, schema)));
|
||||
NamedList<Explanation> explainO
|
||||
= getExplanations(query, otherResults, searcher, schema);
|
||||
dbg.add("explainOther", explainStruct ?
|
||||
explanationsToNamedLists(explainO) :
|
||||
explanationsToStrings(explainO));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -489,6 +493,15 @@ public class SolrPluginUtils {
|
|||
return explainList;
|
||||
}
|
||||
|
||||
private static NamedList<String> explanationsToStrings
|
||||
(NamedList<Explanation> explanations) {
|
||||
|
||||
NamedList<String> out = new SimpleOrderedMap<String>();
|
||||
for (Map.Entry<String,Explanation> entry : explanations) {
|
||||
out.add(entry.getKey(), "\n"+entry.getValue().toString());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an list of Explanations for each item in a list of docs.
|
||||
|
@ -504,15 +517,8 @@ public class SolrPluginUtils {
|
|||
SolrIndexSearcher searcher,
|
||||
IndexSchema schema)
|
||||
throws IOException {
|
||||
|
||||
NamedList<String> outList = new SimpleOrderedMap<String>();
|
||||
NamedList<Explanation> explainList =
|
||||
getExplanations(query,docs,searcher,schema);
|
||||
|
||||
for (Map.Entry<String,Explanation> entry : explainList) {
|
||||
outList.add(entry.getKey(), "\n"+entry.getValue().toString());
|
||||
}
|
||||
return outList;
|
||||
return explanationsToStrings(getExplanations(query,docs,searcher,schema));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue