mirror of https://github.com/apache/lucene.git
SOLR-1665: Add more control to debug via options for timings, etc.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@990577 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
13fd70521a
commit
0bb2e73041
|
@ -250,6 +250,7 @@ New Features
|
|||
allows you to customize how WordDelimiterFilter tokenizes text with
|
||||
a configuration file. (Peter Karich, rmuir)
|
||||
|
||||
* SOLR-1665: Add debug component options for timings, results and query info only (gsingers, hossman, yonik)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
|
|
@ -58,9 +58,29 @@ public interface CommonParams {
|
|||
/** default query field */
|
||||
public static final String DF = "df";
|
||||
|
||||
/** whether to include debug data */
|
||||
/** whether to include debug data for all components pieces, including doing explains*/
|
||||
public static final String DEBUG_QUERY = "debugQuery";
|
||||
|
||||
/**
|
||||
* Whether to provide debug info for specific items.
|
||||
*
|
||||
* @see #DEBUG_QUERY
|
||||
*/
|
||||
public static final String DEBUG = "debug";
|
||||
|
||||
/**
|
||||
* {@link #DEBUG} value indicating an interest in debug output related to timing
|
||||
*/
|
||||
public static final String TIMING = "timing";
|
||||
/**
|
||||
* {@link #DEBUG} value indicating an interest in debug output related to the results (explains)
|
||||
*/
|
||||
public static final String RESULTS = "results";
|
||||
/**
|
||||
* {@link #DEBUG} value indicating an interest in debug output related to the Query (parsing, etc.)
|
||||
*/
|
||||
public static final String QUERY = "query";
|
||||
|
||||
/**
|
||||
* boolean indicating whether score explanations should structured (true),
|
||||
* or plain text (false)
|
||||
|
|
|
@ -23,9 +23,12 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
|
@ -56,6 +59,7 @@ import org.apache.solr.search.DocList;
|
|||
import org.apache.solr.search.DocListAndSet;
|
||||
import org.apache.solr.search.QueryParsing;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
|
||||
import org.apache.solr.util.SolrPluginUtils;
|
||||
|
||||
/**
|
||||
|
@ -192,26 +196,43 @@ public class MoreLikeThisHandler extends RequestHandlerBase
|
|||
rsp.add( "facet_counts", f.getFacetCounts() );
|
||||
}
|
||||
}
|
||||
boolean dbg = req.getParams().getBool(CommonParams.DEBUG_QUERY, false);
|
||||
|
||||
boolean dbgQuery = false, dbgResults = false;
|
||||
if (dbg == false){//if it's true, we are doing everything anyway.
|
||||
String[] dbgParams = req.getParams().getParams(CommonParams.DEBUG);
|
||||
for (int i = 0; i < dbgParams.length; i++) {
|
||||
if (dbgParams[i].equals(CommonParams.QUERY)){
|
||||
dbgQuery = true;
|
||||
} else if (dbgParams[i].equals(CommonParams.RESULTS)){
|
||||
dbgResults = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dbgQuery = true;
|
||||
dbgResults = true;
|
||||
}
|
||||
// Copied from StandardRequestHandler... perhaps it should be added to doStandardDebug?
|
||||
if (dbg == true) {
|
||||
try {
|
||||
NamedList<Object> dbg = SolrPluginUtils.doStandardDebug(req, q, mlt.mltquery, mltDocs.docList );
|
||||
if (null != dbg) {
|
||||
NamedList<Object> dbgInfo = SolrPluginUtils.doStandardDebug(req, q, mlt.mltquery, mltDocs.docList, dbgQuery, dbgResults);
|
||||
if (null != dbgInfo) {
|
||||
if (null != filters) {
|
||||
dbg.add("filter_queries",req.getParams().getParams(CommonParams.FQ));
|
||||
dbgInfo.add("filter_queries",req.getParams().getParams(CommonParams.FQ));
|
||||
List<String> fqs = new ArrayList<String>(filters.size());
|
||||
for (Query fq : filters) {
|
||||
fqs.add(QueryParsing.toString(fq, req.getSchema()));
|
||||
}
|
||||
dbg.add("parsed_filter_queries",fqs);
|
||||
dbgInfo.add("parsed_filter_queries",fqs);
|
||||
}
|
||||
rsp.add("debug", dbg);
|
||||
rsp.add("debug", dbgInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SolrException.logOnce(SolrCore.log, "Exception during debug", e);
|
||||
rsp.add("exception_during_debug", SolrException.toStr(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class InterestingTerm
|
||||
{
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
package org.apache.solr.handler.component;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.FQ;
|
||||
import org.apache.solr.common.params.HighlightParams;
|
||||
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
@ -51,8 +52,9 @@ public class DebugComponent extends SearchComponent
|
|||
public void process(ResponseBuilder rb) throws IOException
|
||||
{
|
||||
if( rb.isDebug() ) {
|
||||
|
||||
NamedList stdinfo = SolrPluginUtils.doStandardDebug( rb.req,
|
||||
rb.getQueryString(), rb.getQuery(), rb.getResults().docList);
|
||||
rb.getQueryString(), rb.getQuery(), rb.getResults().docList, rb.isDebugQuery(), rb.isDebugResults());
|
||||
|
||||
NamedList info = rb.getDebugInfo();
|
||||
if( info == null ) {
|
||||
|
@ -63,12 +65,12 @@ public class DebugComponent extends SearchComponent
|
|||
info.addAll( stdinfo );
|
||||
}
|
||||
|
||||
if (rb.getQparser() != null) {
|
||||
if (rb.isDebugQuery() && rb.getQparser() != null) {
|
||||
rb.getQparser().addDebugInfo(rb.getDebugInfo());
|
||||
}
|
||||
|
||||
if (null != rb.getDebugInfo() ) {
|
||||
if (null != rb.getFilters() ) {
|
||||
if (rb.isDebugQuery() && null != rb.getFilters() ) {
|
||||
info.add("filter_queries",rb.req.getParams().getParams(FQ));
|
||||
List<String> fqs = new ArrayList<String>(rb.getFilters().size());
|
||||
for (Query fq : rb.getFilters()) {
|
||||
|
@ -90,9 +92,9 @@ public class DebugComponent extends SearchComponent
|
|||
// Turn on debug to get explain only when retrieving fields
|
||||
if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) {
|
||||
sreq.purpose |= ShardRequest.PURPOSE_GET_DEBUG;
|
||||
sreq.params.set("debugQuery", "true");
|
||||
sreq.params.set(CommonParams.DEBUG_QUERY, "true");
|
||||
} else {
|
||||
sreq.params.set("debugQuery", "false");
|
||||
sreq.params.set(CommonParams.DEBUG_QUERY, "false");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.QueryElevationParams;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -406,9 +408,11 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
|
|||
SimpleOrderedMap<Object> dbg = new SimpleOrderedMap<Object>();
|
||||
dbg.add( "q", qstr );
|
||||
dbg.add( "match", match );
|
||||
if (rb.isDebugQuery()) {
|
||||
rb.addDebugInfo("queryBoosting", dbg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ResponseBuilder rb) throws IOException {
|
||||
|
|
|
@ -26,11 +26,15 @@ import org.apache.solr.request.SolrQueryRequest;
|
|||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.search.DocListAndSet;
|
||||
import org.apache.solr.search.QParser;
|
||||
import org.apache.solr.search.SortSpec;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.search.SortSpec;
|
||||
import org.apache.solr.util.SolrPluginUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class is experimental and will be changing in the future.
|
||||
|
@ -38,8 +42,9 @@ import java.util.Map;
|
|||
* @version $Id$
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class ResponseBuilder
|
||||
{
|
||||
public class ResponseBuilder {
|
||||
|
||||
|
||||
public SolrQueryRequest req;
|
||||
public SolrQueryResponse rsp;
|
||||
public boolean doHighlights;
|
||||
|
@ -50,7 +55,8 @@ public class ResponseBuilder
|
|||
private boolean needDocList = false;
|
||||
private boolean needDocSet = false;
|
||||
private int fieldFlags = 0;
|
||||
private boolean debug = false;
|
||||
//private boolean debug = false;
|
||||
private boolean debugTimings, debugQuery, debugResults;
|
||||
|
||||
private QParser qparser = null;
|
||||
private String queryString = null;
|
||||
|
@ -76,14 +82,15 @@ public class ResponseBuilder
|
|||
public static final String SHARDS = "shards";
|
||||
public static final String IDS = "ids";
|
||||
|
||||
/***
|
||||
public static final String NUMDOCS = "nd";
|
||||
public static final String DOCFREQS = "tdf";
|
||||
public static final String TERMS = "terms";
|
||||
public static final String EXTRACT_QUERY_TERMS = "eqt";
|
||||
public static final String LOCAL_SHARD = "local";
|
||||
public static final String DOC_QUERY = "dq";
|
||||
***/
|
||||
/**
|
||||
* public static final String NUMDOCS = "nd";
|
||||
* public static final String DOCFREQS = "tdf";
|
||||
* public static final String TERMS = "terms";
|
||||
* public static final String EXTRACT_QUERY_TERMS = "eqt";
|
||||
* public static final String LOCAL_SHARD = "local";
|
||||
* public static final String DOC_QUERY = "dq";
|
||||
* *
|
||||
*/
|
||||
|
||||
public static int STAGE_START = 0;
|
||||
public static int STAGE_PARSE_QUERY = 1000;
|
||||
|
@ -151,11 +158,37 @@ public class ResponseBuilder
|
|||
//-------------------------------------------------------------------------
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
return debugQuery || debugTimings || debugResults;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
public void setDebug(boolean dbg){
|
||||
debugQuery = dbg;
|
||||
debugTimings = dbg;
|
||||
debugResults = dbg;
|
||||
}
|
||||
|
||||
public boolean isDebugTimings() {
|
||||
return debugTimings;
|
||||
}
|
||||
|
||||
public void setDebugTimings(boolean debugTimings) {
|
||||
this.debugTimings = debugTimings;
|
||||
}
|
||||
|
||||
public boolean isDebugQuery() {
|
||||
return debugQuery;
|
||||
}
|
||||
|
||||
public void setDebugQuery(boolean debugQuery) {
|
||||
this.debugQuery = debugQuery;
|
||||
}
|
||||
|
||||
public boolean isDebugResults() {
|
||||
return debugResults;
|
||||
}
|
||||
|
||||
public void setDebugResults(boolean debugResults) {
|
||||
this.debugResults = debugResults;
|
||||
}
|
||||
|
||||
public NamedList<Object> getDebugInfo() {
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.solr.handler.component;
|
|||
import org.apache.solr.handler.RequestHandlerBase;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.RTimer;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.ShardParams;
|
||||
|
@ -32,7 +31,8 @@ import org.apache.solr.client.solrj.SolrRequest;
|
|||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
|
||||
import org.apache.solr.client.solrj.impl.BinaryResponseParser;
|
||||
|
||||
import org.apache.solr.util.SolrPluginUtils;
|
||||
import org.apache.solr.util.plugin.SolrCoreAware;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
|
@ -175,7 +175,11 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware
|
|||
rb.req = req;
|
||||
rb.rsp = rsp;
|
||||
rb.components = components;
|
||||
rb.setDebug(req.getParams().getBool(CommonParams.DEBUG_QUERY, false));
|
||||
boolean dbg = req.getParams().getBool(CommonParams.DEBUG_QUERY, false);
|
||||
rb.setDebug(dbg);
|
||||
if (dbg == false){//if it's true, we are doing everything anyway.
|
||||
SolrPluginUtils.getDebugInterests(req.getParams().getParams(CommonParams.DEBUG), rb);
|
||||
}
|
||||
|
||||
final RTimer timer = rb.isDebug() ? new RTimer() : null;
|
||||
|
||||
|
@ -218,10 +222,9 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware
|
|||
timer.stop();
|
||||
|
||||
// add the timing info
|
||||
if( rb.getDebugInfo() == null ) {
|
||||
rb.setDebugInfo( new SimpleOrderedMap<Object>() );
|
||||
if (rb.isDebugTimings()) {
|
||||
rb.addDebugInfo("timing", timer.asNamedList() );
|
||||
}
|
||||
rb.getDebugInfo().add( "timing", timer.asNamedList() );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.lucene.queryParser.ParseException;
|
|||
import org.apache.lucene.queryParser.QueryParser;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.index.LogByteSizeMergePolicy;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.SolrException;
|
||||
|
@ -34,6 +33,7 @@ import org.apache.solr.common.util.NamedList;
|
|||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.handler.component.ResponseBuilder;
|
||||
import org.apache.solr.highlight.SolrHighlighter;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
|
@ -269,85 +269,26 @@ public class SolrPluginUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns a NamedList containing many "standard" pieces of debugging
|
||||
* information.
|
||||
* </p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>rawquerystring - the 'q' param exactly as specified by the client
|
||||
* </li>
|
||||
* <li>querystring - the 'q' param after any preprocessing done by the plugin
|
||||
* </li>
|
||||
* <li>parsedquery - the main query executed formated by the Solr
|
||||
* QueryParsing utils class (which knows about field types)
|
||||
* </li>
|
||||
* <li>parsedquery_toString - the main query executed formated by it's
|
||||
* own toString method (in case it has internal state Solr
|
||||
* doesn't know about)
|
||||
* </li>
|
||||
* <li>expain - the list of score explanations for each document in
|
||||
* results against query.
|
||||
* </li>
|
||||
* <li>otherQuery - the query string specified in 'explainOther' query param.
|
||||
* </li>
|
||||
* <li>explainOther - the list of score explanations for each document in
|
||||
* results against 'otherQuery'
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param req the request we are dealing with
|
||||
* @param userQuery the users query as a string, after any basic
|
||||
* preprocessing has been done
|
||||
* @param query the query built from the userQuery
|
||||
* (and perhaps other clauses) that identifies the main
|
||||
* result set of the response.
|
||||
* @param results the main result set of the response
|
||||
* @deprecated Use doStandardDebug(SolrQueryRequest,String,Query,DocList) with setDefaults
|
||||
*/
|
||||
public static NamedList doStandardDebug(SolrQueryRequest req,
|
||||
String userQuery,
|
||||
Query query,
|
||||
DocList results,
|
||||
org.apache.solr.util.CommonParams params)
|
||||
throws IOException {
|
||||
|
||||
String debug = getParam(req, CommonParams.DEBUG_QUERY, params.debugQuery);
|
||||
|
||||
NamedList dbg = null;
|
||||
if (debug!=null) {
|
||||
dbg = new SimpleOrderedMap();
|
||||
|
||||
/* userQuery may have been pre-processes .. expose that */
|
||||
dbg.add("rawquerystring", req.getQueryString());
|
||||
dbg.add("querystring", userQuery);
|
||||
|
||||
/* 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, req.getSchema()));
|
||||
dbg.add("parsedquery_toString", query.toString());
|
||||
|
||||
dbg.add("explain", getExplainList
|
||||
(query, results, req.getSearcher(), req.getSchema()));
|
||||
String otherQueryS = req.getParam("explainOther");
|
||||
if (otherQueryS != null && otherQueryS.length() > 0) {
|
||||
DocList otherResults = doSimpleQuery
|
||||
(otherQueryS,req.getSearcher(), req.getSchema(),0,10);
|
||||
dbg.add("otherQuery",otherQueryS);
|
||||
dbg.add("explainOther", getExplainList
|
||||
(query, otherResults,
|
||||
req.getSearcher(),
|
||||
req.getSchema()));
|
||||
public static Set<String> getDebugInterests(String[] params, ResponseBuilder rb){
|
||||
Set<String> debugInterests = new HashSet<String>();
|
||||
if (params != null) {
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (params[i].equalsIgnoreCase("all") || params[i].equalsIgnoreCase("true")){
|
||||
rb.setDebug(true);
|
||||
break;
|
||||
//still might add others
|
||||
} else if (params[i].equals(CommonParams.TIMING)){
|
||||
rb.setDebugTimings(true);
|
||||
} else if (params[i].equals(CommonParams.QUERY)){
|
||||
rb.setDebugQuery(true);
|
||||
} else if (params[i].equals(CommonParams.RESULTS)){
|
||||
rb.setDebugResults(true);
|
||||
}
|
||||
}
|
||||
|
||||
return dbg;
|
||||
}
|
||||
|
||||
|
||||
return debugInterests;
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Returns a NamedList containing many "standard" pieces of debugging
|
||||
|
@ -383,17 +324,17 @@ public class SolrPluginUtils {
|
|||
* (and perhaps other clauses) that identifies the main
|
||||
* result set of the response.
|
||||
* @param results the main result set of the response
|
||||
* @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)
|
||||
DocList results, boolean dbgQuery, boolean dbgResults)
|
||||
throws IOException {
|
||||
|
||||
String debug = req.getParams().get(CommonParams.DEBUG_QUERY);
|
||||
|
||||
NamedList dbg = null;
|
||||
if (debug!=null) {
|
||||
|
||||
dbg = new SimpleOrderedMap();
|
||||
|
||||
SolrIndexSearcher searcher = req.getSearcher();
|
||||
|
@ -403,6 +344,7 @@ public class SolrPluginUtils {
|
|||
= req.getParams().getBool(CommonParams.EXPLAIN_STRUCT, false);
|
||||
|
||||
/* userQuery may have been pre-processes .. expose that */
|
||||
if (dbgQuery) {
|
||||
dbg.add("rawquerystring", req.getParams().get(CommonParams.Q));
|
||||
dbg.add("querystring", userQuery);
|
||||
|
||||
|
@ -412,7 +354,9 @@ public class SolrPluginUtils {
|
|||
*/
|
||||
dbg.add("parsedquery", QueryParsing.toString(query, schema));
|
||||
dbg.add("parsedquery_toString", query.toString());
|
||||
}
|
||||
|
||||
if (dbgResults) {
|
||||
NamedList<Explanation> explain
|
||||
= getExplanations(query, results, searcher, schema);
|
||||
dbg.add("explain", explainStruct ?
|
||||
|
@ -432,6 +376,7 @@ public class SolrPluginUtils {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return dbg;
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
|
|||
assertQ(req("text:hello")
|
||||
,"//*[@numFound='2']"
|
||||
);
|
||||
String resp = h.query(lrf.makeRequest("q", "text:hello", "debugQuery", "true"));
|
||||
String resp = h.query(lrf.makeRequest("q", "text:hello", CommonParams.DEBUG_QUERY, "true"));
|
||||
//System.out.println(resp);
|
||||
// second doc ranked first
|
||||
assertTrue( resp.indexOf("\"2\"") < resp.indexOf("\"1\"") );
|
||||
|
@ -290,7 +290,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
|
|||
assertQ(req("text:hello"),
|
||||
"//*[@numFound='2']"
|
||||
);
|
||||
String resp = h.query(lrf.makeRequest("q", "text:hello", "debugQuery", "true"));
|
||||
String resp = h.query(lrf.makeRequest("q", "text:hello", CommonParams.DEBUG_QUERY, "true"));
|
||||
//System.out.println(resp);
|
||||
// second doc ranked first
|
||||
assertTrue( resp.indexOf("\"2\"") < resp.indexOf("\"1\"") );
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.solr;
|
||||
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -120,7 +121,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
|
|||
,"version", "2.0"
|
||||
,"bq", "subject:hell^400"
|
||||
,"bq", "subject:cool^4"
|
||||
,"debugQuery", "true"
|
||||
, CommonParams.DEBUG_QUERY, "true"
|
||||
)
|
||||
,"//*[@numFound='3']"
|
||||
,"//result/doc[1]/int[@name='id'][.='666']"
|
||||
|
@ -179,7 +180,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
|
|||
,"qt", "dismax"
|
||||
,"version", "2.0"
|
||||
,"bq", "subject:hell OR subject:cool"
|
||||
,"debugQuery", "true"
|
||||
,CommonParams.DEBUG_QUERY, "true"
|
||||
));
|
||||
assertTrue(p.matcher(resp).find());
|
||||
assertFalse(p_bool.matcher(resp).find());
|
||||
|
@ -189,7 +190,7 @@ public class DisMaxRequestHandlerTest extends SolrTestCaseJ4 {
|
|||
,"version", "2.0"
|
||||
,"bq", "subject:hell OR subject:cool"
|
||||
,"bq",""
|
||||
,"debugQuery", "true"
|
||||
,CommonParams.DEBUG_QUERY, "true"
|
||||
));
|
||||
assertTrue(p.matcher(resp).find());
|
||||
assertTrue(p_bool.matcher(resp).find());
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.solr;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
|
||||
/**
|
||||
* TODO? perhaps use:
|
||||
|
@ -133,7 +134,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
|
|||
handle.put("time", SKIPVAL);
|
||||
|
||||
query("q","now their fox sat had put","fl","*,score",
|
||||
"debugQuery", "true");
|
||||
CommonParams.DEBUG_QUERY, "true");
|
||||
|
||||
// TODO: This test currently fails because debug info is obtained only
|
||||
// on shards with matches.
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
package org.apache.solr.handler.component;
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
**/
|
||||
public class DebugComponentTest extends SolrTestCaseJ4 {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig.xml", "schema.xml");
|
||||
assertU(adoc("id", "1", "title", "this is a title."));
|
||||
assertU(adoc("id", "2", "title", "this is another title."));
|
||||
assertU(adoc("id", "3", "title", "Mary had a little lamb."));
|
||||
assertU(commit());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicInterface() throws Exception {
|
||||
//make sure the basics are in place
|
||||
assertQ(req("q", "*:*", CommonParams.DEBUG_QUERY, "true"),
|
||||
"//str[@name='rawquerystring']='*:*'",
|
||||
"//str[@name='querystring']='*:*'",
|
||||
"//str[@name='parsedquery']='MatchAllDocsQuery(*:*)'",
|
||||
"//str[@name='parsedquery_toString']='*:*'",
|
||||
"count(//lst[@name='explain']/*)=3",
|
||||
"//lst[@name='explain']/str[@name='1']",
|
||||
"//lst[@name='explain']/str[@name='2']",
|
||||
"//lst[@name='explain']/str[@name='3']",
|
||||
"//str[@name='QParser']",// make sure the QParser is specified
|
||||
"count(//lst[@name='timing']/*)=3", //should be three pieces to timings
|
||||
"//lst[@name='timing']/double[@name='time']", //make sure we have a time value, but don't specify it's result
|
||||
"count(//lst[@name='prepare']/*)>0",
|
||||
"//lst[@name='prepare']/double[@name='time']",
|
||||
"count(//lst[@name='process']/*)>0",
|
||||
"//lst[@name='process']/double[@name='time']"
|
||||
);
|
||||
}
|
||||
|
||||
// Test the ability to specify which pieces to include
|
||||
|
||||
@Test
|
||||
public void testPerItemInterface() throws Exception {
|
||||
//Same as debugQuery = true
|
||||
assertQ(req("q", "*:*", "debug", "true"),
|
||||
"//str[@name='rawquerystring']='*:*'",
|
||||
"//str[@name='querystring']='*:*'",
|
||||
"//str[@name='parsedquery']='MatchAllDocsQuery(*:*)'",
|
||||
"//str[@name='parsedquery_toString']='*:*'",
|
||||
"//str[@name='QParser']",// make sure the QParser is specified
|
||||
"count(//lst[@name='explain']/*)=3",
|
||||
"//lst[@name='explain']/str[@name='1']",
|
||||
"//lst[@name='explain']/str[@name='2']",
|
||||
"//lst[@name='explain']/str[@name='3']",
|
||||
"count(//lst[@name='timing']/*)=3", //should be three pieces to timings
|
||||
"//lst[@name='timing']/double[@name='time']", //make sure we have a time value, but don't specify it's result
|
||||
"count(//lst[@name='prepare']/*)>0",
|
||||
"//lst[@name='prepare']/double[@name='time']",
|
||||
"count(//lst[@name='process']/*)>0",
|
||||
"//lst[@name='process']/double[@name='time']"
|
||||
);
|
||||
//timing only
|
||||
assertQ(req("q", "*:*", "debug", CommonParams.TIMING),
|
||||
"count(//str[@name='rawquerystring'])=0",
|
||||
"count(//str[@name='querystring'])=0",
|
||||
"count(//str[@name='parsedquery'])=0",
|
||||
"count(//str[@name='parsedquery_toString'])=0",
|
||||
"count(//lst[@name='explain']/*)=0",
|
||||
"count(//str[@name='QParser'])=0",// make sure the QParser is specified
|
||||
"count(//lst[@name='timing']/*)=3", //should be three pieces to timings
|
||||
"//lst[@name='timing']/double[@name='time']", //make sure we have a time value, but don't specify it's result
|
||||
"count(//lst[@name='prepare']/*)>0",
|
||||
"//lst[@name='prepare']/double[@name='time']",
|
||||
"count(//lst[@name='process']/*)>0",
|
||||
"//lst[@name='process']/double[@name='time']"
|
||||
);
|
||||
//query only
|
||||
assertQ(req("q", "*:*", "debug", CommonParams.QUERY),
|
||||
"//str[@name='rawquerystring']='*:*'",
|
||||
"//str[@name='querystring']='*:*'",
|
||||
"//str[@name='parsedquery']='MatchAllDocsQuery(*:*)'",
|
||||
"//str[@name='parsedquery_toString']='*:*'",
|
||||
"count(//lst[@name='explain']/*)=0",
|
||||
"//str[@name='QParser']",// make sure the QParser is specified
|
||||
"count(//lst[@name='timing']/*)=0"
|
||||
|
||||
);
|
||||
|
||||
//explains
|
||||
assertQ(req("q", "*:*", "debug", CommonParams.RESULTS),
|
||||
"count(//str[@name='rawquerystring'])=0",
|
||||
"count(//str[@name='querystring'])=0",
|
||||
"count(//str[@name='parsedquery'])=0",
|
||||
"count(//str[@name='parsedquery_toString'])=0",
|
||||
"count(//lst[@name='explain']/*)=3",
|
||||
"//lst[@name='explain']/str[@name='1']",
|
||||
"//lst[@name='explain']/str[@name='2']",
|
||||
"//lst[@name='explain']/str[@name='3']",
|
||||
"count(//str[@name='QParser'])=0",// make sure the QParser is specified
|
||||
"count(//lst[@name='timing']/*)=0"
|
||||
);
|
||||
|
||||
assertQ(req("q", "*:*", "debug", CommonParams.RESULTS,
|
||||
"debug", CommonParams.QUERY),
|
||||
"//str[@name='rawquerystring']='*:*'",
|
||||
"//str[@name='querystring']='*:*'",
|
||||
"//str[@name='parsedquery']='MatchAllDocsQuery(*:*)'",
|
||||
"//str[@name='parsedquery_toString']='*:*'",
|
||||
"//str[@name='QParser']",// make sure the QParser is specified
|
||||
|
||||
"count(//lst[@name='explain']/*)=3",
|
||||
"//lst[@name='explain']/str[@name='1']",
|
||||
"//lst[@name='explain']/str[@name='2']",
|
||||
"//lst[@name='explain']/str[@name='3']",
|
||||
|
||||
"count(//lst[@name='timing']/*)=0"
|
||||
);
|
||||
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.solr.search;
|
||||
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
|
||||
public class TestQueryTypes extends AbstractSolrTestCase {
|
||||
|
@ -262,7 +263,7 @@ public class TestQueryTypes extends AbstractSolrTestCase {
|
|||
,"qf","v_t"
|
||||
,"bf","sqrt(v_f)^100 log(sum(v_f,1))^50"
|
||||
,"bq","{!prefix f=v_t}he"
|
||||
,"debugQuery","on"
|
||||
, CommonParams.DEBUG_QUERY,"on"
|
||||
)
|
||||
,"//result[@numFound='2']"
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue