Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/SOLR-18458.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: >
Remove the legacy `debugQuery` request parameter.
type: removed
authors:
- name: Nick Shanin
links:
- name: SOLR-18458
url: https://issues.apache.org/jira/browse/SOLR-18458
25 changes: 10 additions & 15 deletions solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,20 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
rsp.add("facet_counts", FacetComponent.getFacetCounts(f));
}
}
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);
if (dbgParams != null) {
for (String dbgParam : dbgParams) {
if (dbgParam.equals(CommonParams.QUERY)) {
dbgQuery = true;
} else if (dbgParam.equals(CommonParams.RESULTS)) {
dbgResults = true;
}
String[] dbgParams = req.getParams().getParams(CommonParams.DEBUG);
if (dbgParams != null) {
for (String dbgParam : dbgParams) {
boolean debugAll = "all".equalsIgnoreCase(dbgParam) || "true".equalsIgnoreCase(dbgParam);
if (debugAll || CommonParams.QUERY.equals(dbgParam)) {
dbgQuery = true;
}
if (debugAll || CommonParams.RESULTS.equals(dbgParam)) {
dbgResults = true;
}
}
} else {
dbgQuery = true;
dbgResults = true;
}
if (dbg == true) {
if (dbgQuery || dbgResults) {
try {
NamedList<Object> dbgInfo =
DebugComponent.doStandardDebug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest
statsCache.sendGlobalStats(rb, sreq);

if (rb.isDebugAll()) {
sreq.params.set(CommonParams.DEBUG_QUERY, "true");
sreq.params.set(CommonParams.DEBUG, "true");
} else {
if (rb.isDebugQuery()) {
sreq.params.add(CommonParams.DEBUG, CommonParams.QUERY);
Expand All @@ -173,7 +173,6 @@ public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest
}
}
} else {
sreq.params.set(CommonParams.DEBUG_QUERY, "false");
sreq.params.set(CommonParams.DEBUG, "false");
}
if (rb.isDebugTimings()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw

rb.isDistrib = isDistrib(req, rb); // can change later nonetheless

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);
}
SolrPluginUtils.getDebugInterests(req.getParams().getParams(CommonParams.DEBUG), rb);

if (checkCircuitBreakers(req, rsp, rb)) {
return; // Circuit breaker tripped, return immediately
Expand Down
28 changes: 8 additions & 20 deletions solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,17 @@ private boolean isExplainResults() {
}
}

// HACK: The code below should not be used. It is preserved for backcompat
// on the slim remote chance that someone is using ReRankQParserPlugin
// w/o using SearchHandler+ResponseBuilder
//
// (It's also wrong, and doesn't account for thigns like debug=true
// or debug=all ... but as stated: it's for esoteric backcompat purposes
// only, so we're not going to change it and start returning "true"
// if existing code doesn't expect it

boolean debugQuery = params.getBool(CommonParams.DEBUG_QUERY, false);

if (!debugQuery) {
String[] debugParams = params.getParams(CommonParams.DEBUG);
if (debugParams != null) {
for (String debugParam : debugParams) {
if ("true".equals(debugParam)) {
debugQuery = true;
break;
}
// HACK: The code below is only for the slim chance that this parser is used without
// SearchHandler+ResponseBuilder. In that case, honor the debug settings in the request.
String[] debugParams = params.getParams(CommonParams.DEBUG);
if (debugParams != null) {
for (String debugParam : debugParams) {
if ("all".equalsIgnoreCase(debugParam) || "true".equalsIgnoreCase(debugParam)) {
return true;
}
}
}
return debugQuery;
return false;
}

public ReRankQParser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public void testDocBoost() throws Exception {
// assertEquals("<result status=\"0\"></result>", res);
assertU("<commit/>");
assertQ(req("text:hello"), "//*[@numFound='2']");
String resp = h.query(lrf.makeRequest("q", "text:hello", CommonParams.DEBUG_QUERY, "true"));
String resp = h.query(lrf.makeRequest("q", "text:hello", CommonParams.DEBUG, "true"));
// System.out.println(resp);
// second doc ranked first
assertTrue(resp.indexOf("\"2\"") < resp.indexOf("\"1\""));
Expand All @@ -490,7 +490,7 @@ public void testFieldBoost() throws Exception {
// assertEquals("<result status=\"0\"></result>", res);
assertU("<commit/>");
assertQ(req("text:hello"), "//*[@numFound='2']");
String resp = h.query(lrf.makeRequest("q", "text:hello", CommonParams.DEBUG_QUERY, "true"));
String resp = h.query(lrf.makeRequest("q", "text:hello", CommonParams.DEBUG, "true"));
// System.out.println(resp);
// second doc ranked first
assertTrue(resp.indexOf("\"2\"") < resp.indexOf("\"1\""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void doTestSomeStuff(final String handler) {
"subject:hell^400",
"bq",
"subject:cool^4",
CommonParams.DEBUG_QUERY,
CommonParams.DEBUG,
"true"),
"//*[@numFound='3']",
"//result/doc[1]/str[@name='id'][.='666']",
Expand Down Expand Up @@ -225,7 +225,7 @@ public void testExtraBlankBQ() throws Exception {
"cool stuff",
"bq",
"subject:hell OR subject:cool",
CommonParams.DEBUG_QUERY,
CommonParams.DEBUG,
"true"));
assertTrue(p.matcher(resp).find());
assertFalse(p_bool.matcher(resp).find());
Expand All @@ -240,7 +240,7 @@ public void testExtraBlankBQ() throws Exception {
"subject:hell OR subject:cool",
"bq",
"",
CommonParams.DEBUG_QUERY,
CommonParams.DEBUG,
"true"));
assertTrue(p.matcher(resp).find());
assertTrue(p_bool.matcher(resp).find());
Expand Down
6 changes: 3 additions & 3 deletions solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void doTestJoin(String joinPrefix) throws Exception {
joinPrefix + " from=dept_id_s to=dept_s fromIndex=fromCore}cat:dev",
"fl",
"id",
"debugQuery",
"debug",
random().nextBoolean() ? "true" : "false"),
"/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'1'},{'id':'4'},{'id':'5'}]}");

Expand All @@ -159,7 +159,7 @@ void doTestJoin(String joinPrefix) throws Exception {
"id_s_dv",
"sort",
"id_s_dv asc",
"debugQuery",
"debug",
random().nextBoolean() ? "true" : "false"),
"/response=={'numFound':3,'docs':[{'id_s_dv':'1'},{'id_s_dv':'4'},{'id_s_dv':'5'}]}");
assertFalse(fromCore.isClosed());
Expand All @@ -175,7 +175,7 @@ void doTestJoin(String joinPrefix) throws Exception {
"id",
"fq",
"name:john",
"debugQuery",
"debug",
random().nextBoolean() ? "true" : "false"),
"/response=={'numFound':1,'start':0,'numFoundExact':true,'docs':[{'id':'1'}]}");
}
Expand Down
6 changes: 3 additions & 3 deletions solr/core/src/test/org/apache/solr/TestDistributedSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -1523,8 +1523,8 @@ public void test() throws Exception {
handle.put("debug", UNORDERED);
handle.put("time", SKIPVAL);
handle.put("track", SKIP); // track is not included in single node search
query("q", "now their fox sat had put", "fl", "*,score", CommonParams.DEBUG_QUERY, "true");
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG_QUERY, "true");
query("q", "now their fox sat had put", "fl", "*,score", CommonParams.DEBUG, "true");
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG, "true");
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.TIMING);
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.RESULTS);
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.QUERY);
Expand Down Expand Up @@ -1689,7 +1689,7 @@ public void test() throws Exception {

// TODO: This test currently fails because debug info is obtained only
// on shards with matches.
// query("q","matchesnothing","fl","*,score", "debugQuery", "true");
// query("q","matchesnothing","fl","*,score", "debug", "true");

// Thread.sleep(10000000000L);

Expand Down
2 changes: 1 addition & 1 deletion solr/core/src/test/org/apache/solr/TestGroupingSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ public void testGroupAPI() throws Exception {
f,
"fl",
"id",
"debugQuery",
"debug",
"true"),
"/grouped/" + f + "/matches==10",
"/debug/explain/8==",
Expand Down
10 changes: 5 additions & 5 deletions solr/core/src/test/org/apache/solr/TestJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void testJoinAllMethods() throws Exception {
buildJoinRequest(DEPT_FIELD, DEPT_ID_FIELD, "title:MTS"),
"fl",
"id",
"debugQuery",
"debug",
"true"),
"/response=={'numFound':3,'start':0,'numFoundExact':true,'docs':[{'id':'10'},{'id':'12'},{'id':'13'}]}");

Expand All @@ -199,7 +199,7 @@ public void testJoinAllMethods() throws Exception {
"name",
"fl",
"id",
"debugQuery",
"debug",
"true"),
davesDepartments);

Expand All @@ -213,7 +213,7 @@ public void testJoinAllMethods() throws Exception {
"{!dismax qf=name}dave",
"fl",
"id",
"debugQuery",
"debug",
"true"),
davesDepartments);

Expand All @@ -227,7 +227,7 @@ public void testJoinAllMethods() throws Exception {
"name",
"fl",
"id",
"debugQuery",
"debug",
"true"),
davesDepartments);

Expand Down Expand Up @@ -294,7 +294,7 @@ public void testIndexJoin() throws Exception {
"{!join from=dept_ss_dv to=dept_id_indexed_sdv}title:MTS",
"fl",
"id",
"debugQuery",
"debug",
"true"),
"/debug/join/{!join from=dept_ss_dv to=dept_id_indexed_sdv}title:MTS=={'_MATCH_':'fromSetSize,toSetSize', 'fromSetSize':2, 'toSetSize':3}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ public void testFalsePositives() {
"no reverse, no false positive",
req(
"q", "+id:1 +three:[* TO a]",
"debugQuery", "true"),
"debug", "true"),
"//result[@numFound=0]");
{
String reverseField = random().nextBoolean() ? "one" : "two";
assertQ(
"false positive",
req("q", "+id:1 +" + reverseField + ":[* TO a]", "debugQuery", "true"),
req("q", "+id:1 +" + reverseField + ":[* TO a]", "debug", "true"),
"//result[@numFound=0]");
}
assertQ("false positive", req("+id:1 +two:*zemog*"), "//result[@numFound=0]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ private void bringDownShardIndexSomeDocsAndRecover() throws Exception {
}
// TODO: This test currently fails because debug info is obtained only
// on shards with matches.
// query("q","matchesnothing","fl","*,score", "debugQuery", "true");
// query("q","matchesnothing","fl","*,score", "debug", "true");

// this should trigger a recovery phase on deadShard
deadShard.jetty.start();
Expand Down Expand Up @@ -491,8 +491,8 @@ private void testDebugQueries() throws Exception {
handle.put("debug", UNORDERED);
handle.put("time", SKIPVAL);
handle.put("track", SKIP);
query("q", "now their fox sat had put", "fl", "*,score", CommonParams.DEBUG_QUERY, "true");
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG_QUERY, "true");
query("q", "now their fox sat had put", "fl", "*,score", CommonParams.DEBUG, "true");
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG, "true");
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.TIMING);
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.RESULTS);
query("q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.QUERY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,9 @@ public void test() throws Exception {
query(
false,
new Object[] {
"q", "now their fox sat had put", "fl", "*,score", CommonParams.DEBUG_QUERY, "true"
"q", "now their fox sat had put", "fl", "*,score", CommonParams.DEBUG, "true"
});
query(false, new Object[] {"q", "id_i1:[1 TO 5]", CommonParams.DEBUG_QUERY, "true"});
query(false, new Object[] {"q", "id_i1:[1 TO 5]", CommonParams.DEBUG, "true"});
query(false, new Object[] {"q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.TIMING});
query(false, new Object[] {"q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.RESULTS});
query(false, new Object[] {"q", "id_i1:[1 TO 5]", CommonParams.DEBUG, CommonParams.QUERY});
Expand Down Expand Up @@ -735,7 +735,7 @@ public void test() throws Exception {

// TODO: This test currently fails because debug info is obtained only
// on shards with matches.
// query("q","matchesnothing","fl","*,score", "debugQuery", "true");
// query("q","matchesnothing","fl","*,score", "debug", "true");

// would be better if these where all separate tests - but much, much
// slower
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void testInterface() {
}

// test MoreLikeThis debug
params.set(CommonParams.DEBUG_QUERY, "true");
params.set(CommonParams.DEBUG, "all");
try (SolrQueryRequest mltreq = new SolrQueryRequestBase(core, params)) {
assertQ(
"morelike this - harrison ford",
Expand All @@ -203,7 +203,7 @@ public void testInterface() {
}

// test that qparser plugins work
params.remove(CommonParams.DEBUG_QUERY);
params.remove(CommonParams.DEBUG);
params.set(CommonParams.Q, "{!field f=id}44");
try (SolrQueryRequest mltreq = new SolrQueryRequestBase(core, params)) {
assertQ(mltreq, "//result/doc[1]/str[@name='id'][.='45']");
Expand All @@ -225,8 +225,15 @@ public void testInterface() {
assertQ(mltreq, "//result/doc[1]/str[@name='id'][.='45']");
}

// The legacy parameter must not enable debugging in the standalone handler.
params.set("debugQuery", "true");
try (SolrQueryRequest mltreq = withPath("/mlt", new SolrQueryRequestBase(core, params))) {
assertQ(mltreq, "//result/doc[1]/str[@name='id'][.='45']", "count(//lst[@name='debug'])=0");
}
params.remove("debugQuery");

// test that debugging works (test for MoreLikeThis*Handler*)
params.set(CommonParams.DEBUG_QUERY, "true");
params.set(CommonParams.DEBUG, "all");
try (SolrQueryRequest mltreq = withPath("/mlt", new SolrQueryRequestBase(core, params))) {
assertQ(
mltreq,
Expand Down
Loading
Loading