diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 5f7e1f268dc6..63e67963ca53 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1993,6 +1993,11 @@ public static void verbose(Object... args) {
/**
* Get the request handler registered to a given name.
*
+ *
A {@code null} handlerName resolves to the core's default request handler (whichever handler
+ * is aliased to the empty string, normally the one registered at "/select", or "standard" for
+ * legacy configs) rather than returning {@code null}; see {@link
+ * RequestHandlers#initHandlersFromConfig}.
+ *
*
This function is thread safe.
*/
public SolrRequestHandler getRequestHandler(String handlerName) {
diff --git a/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java b/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
index 9cb5f6ab3aac..ac1a824752f2 100644
--- a/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
+++ b/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
@@ -759,7 +759,7 @@ public void testNotLazyField() throws IOException {
SolrQueryRequest req = req("q", "id:7777", "fl", "id,title,test_hlt");
SolrQueryResponse rsp = new SolrQueryResponse();
- core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
+ core.execute(core.getRequestHandler(null), req, rsp);
DocList dl = ((ResultContext) rsp.getResponse()).getDocList();
Document d = req.getSearcher().getDocFetcher().doc(dl.iterator().nextDoc());
@@ -786,7 +786,7 @@ public void testLazyField() throws IOException {
// initial request
SolrQueryRequest req = req("q", "id:7777", "fl", "id,title");
SolrQueryResponse rsp = new SolrQueryResponse();
- core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
+ core.execute(core.getRequestHandler(null), req, rsp);
DocList dl = ((ResultContext) rsp.getResponse()).getDocList();
DocIterator di = dl.iterator();
@@ -808,7 +808,7 @@ public void testLazyField() throws IOException {
// followup request, different fl
req = req("q", "id:7777", "fl", "id,test_hlt");
rsp = new SolrQueryResponse();
- core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
+ core.execute(core.getRequestHandler(null), req, rsp);
dl = ((ResultContext) rsp.getResponse()).getDocList();
di = dl.iterator();
diff --git a/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java b/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java
index 301e5d778bc6..4845f0a91a7f 100644
--- a/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java
+++ b/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java
@@ -22,7 +22,6 @@
import org.apache.solr.common.params.MultiMapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.util.ErrorLogMuter;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -61,8 +60,7 @@ public void testABunchOfConvertedStuff() {
assertU("");
assertQ(req("val_s:[a TO z]"), "//*[@numFound='3'] ", "*[count(//doc)=3] ", "//*[@start='0']");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 2, 5, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 2, 5, args));
assertQ(
req,
"//*[@numFound='3'] ",
@@ -70,54 +68,42 @@ public void testABunchOfConvertedStuff() {
"*//doc[1]/str[.='pear'] ",
"//*[@start='2']");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 3, 5, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 3, 5, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 4, 5, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 4, 5, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 25, 5, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 25, 5, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 1, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 1, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=1] ", "*//doc[1]/str[.='apple']");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 2, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 2, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=2] ", "*//doc[2]/str[.='banana']");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 1, 1, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 1, 1, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=1] ", "*//doc[1]/str[.='banana']");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 3, 1, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 3, 1, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 4, 1, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 4, 1, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 1, 0, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 1, 0, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 0, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 0, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
args.put("sort", "val_s1 asc");
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 0, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 0, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
args = new HashMap<>();
args.put("sort", "val_s1 desc");
- req =
- new SolrQueryRequestBase(h.getCore(), makeParams("val_s:[a TO z]", "/select", 0, 0, args));
+ req = reqWithPath("/select", makeParams("val_s:[a TO z]", 0, 0, args));
assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
assertQ(req("val_s:[a TO b]"), "//*[@numFound='1']");
assertQ(req("val_s:[a TO cat]"), "//*[@numFound='2']");
@@ -776,18 +762,18 @@ public void testABunchOfConvertedStuff() {
assertQ(req("id:44"));
args = new HashMap<>();
args.put("fl", "fname_s,arr_f ");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135']");
args = new HashMap<>();
args.put("fl", "fname_s,score");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//str[.='Yonik']", "//float[@name='score' and . > 0]");
// test addition of score field
args = new HashMap<>();
args.put("fl", "score,* ");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(
req,
"//str[.='Yonik'] ",
@@ -796,7 +782,7 @@ public void testABunchOfConvertedStuff() {
"*[count(//doc/*)>=13]");
args = new HashMap<>();
args.put("fl", "*,score ");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(
req,
"//str[.='Yonik'] ",
@@ -805,33 +791,33 @@ public void testABunchOfConvertedStuff() {
"*[count(//doc/*)>=13]");
args = new HashMap<>();
args.put("fl", "* ");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135'] ", "*[count(//doc/*)>=12]");
// test maxScore
args = new HashMap<>();
args.put("fl", "score ");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//result[@maxScore>0]");
args = new HashMap<>();
args.put("fl", "score ");
args.put("sort", "id desc");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//result[@maxScore>0]");
args = new HashMap<>();
args.put("fl", "score ");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//@maxScore = //doc/float[@name='score']");
args = new HashMap<>();
args.put("fl", "score ");
args.put("sort", "id desc");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 10, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 10, args));
assertQ(req, "//@maxScore = //doc/float[@name='score']");
args = new HashMap<>();
args.put("fl", "*,score");
args.put("sort", "id desc");
- req = new SolrQueryRequestBase(h.getCore(), makeParams("id:44", "/select", 0, 0, args));
+ req = reqWithPath("/select", makeParams("id:44", 0, 0, args));
assertQ(req, "//result[@maxScore>0]");
// test schema field attribute inheritance and overriding
@@ -908,18 +894,16 @@ public void testABunchOfConvertedStuff() {
/**
* Utility method to build SolrParams from individual query components. This is a convenience
- * method for legacy code that needs to construct params from separate query, qtype, start, limit,
- * and additional args.
+ * method for legacy code that needs to construct params from separate query, start, limit, and
+ * additional args.
*
* @param query the query string (added as "q" param)
- * @param qtype the query type (added as "qt" param)
* @param start the start offset (added as "start" param)
* @param limit the row limit (added as "rows" param)
* @param args additional parameters as a map
* @return SolrParams containing all the specified parameters
*/
- public static SolrParams makeParams(
- String query, String qtype, int start, int limit, Map, ?> args) {
+ public static SolrParams makeParams(String query, int start, int limit, Map, ?> args) {
Map map = new HashMap<>();
for (Map.Entry, ?> e : args.entrySet()) {
String k = e.getKey().toString();
@@ -928,7 +912,6 @@ public static SolrParams makeParams(
else map.put(k, new String[] {v.toString()});
}
if (query != null) map.put(CommonParams.Q, new String[] {query});
- if (qtype != null) map.put(CommonParams.QT, new String[] {qtype});
map.put(CommonParams.START, new String[] {Integer.toString(start)});
map.put(CommonParams.ROWS, new String[] {Integer.toString(limit)});
return new MultiMapSolrParams(map);
diff --git a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
index 0f4d51b936c8..4ae2b55becbb 100644
--- a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
+++ b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
@@ -430,8 +430,7 @@ public void testGroupingSimpleFormatArrayIndexOutOfBoundsExceptionWithJavaBin()
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(request, response));
- String handlerName = request.getParams().get(CommonParams.QT);
- h.getCore().execute(h.getCore().getRequestHandler(handlerName), request, response);
+ h.getCore().execute(h.getCore().getRequestHandler(null), request, response);
JavaBinResponseWriter responseWriter = new JavaBinResponseWriter();
responseWriter.write(out, request, response);
} finally {
diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java
index b6452a5e61e4..767fda282303 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java
@@ -595,7 +595,6 @@ public void doRandomSortsOnLargeIndex() throws Exception {
assertFullWalkNoDupsElevated(
wrapDefaults(
params(
- "qt", "/elevate",
"fl", "id,[elevated]",
"forceElevation", "true",
"elevateIds", "50,20,80"),
@@ -649,8 +648,6 @@ public void doRandomSortsOnLargeIndex() throws Exception {
assertFullWalkNoDupsElevated(
wrapDefaults(
params(
- "qt",
- "/elevate",
"fl",
fl + ",[elevated]",
// HACK: work around SOLR-15307... same results should match, just not same
@@ -782,6 +779,7 @@ public SentinelIntSet assertFullWalkNoDupsElevated(
final SentinelIntSet idsElevated = new SentinelIntSet(32, -1);
assertFullWalkNoDups(
+ "/elevate",
params,
(doc) -> {
final int id = Integer.parseInt(doc.get("id").toString());
@@ -883,8 +881,16 @@ public SentinelIntSet assertFullWalkNoDups(int maxSize, SolrParams params) throw
*/
public void assertFullWalkNoDups(SolrParams params, Consumer consumer)
throws Exception {
+ assertFullWalkNoDups("/select", params, consumer);
+ }
+
+ /**
+ * Identical to {@link #assertFullWalkNoDups(SolrParams,Consumer)}, but dispatches the query to
+ * the specified request handler path.
+ */
+ public void assertFullWalkNoDups(
+ String requestHandler, SolrParams params, Consumer consumer) throws Exception {
- final String requestHandler = params.get(CommonParams.QT, "/select");
String cursorMark = CURSOR_MARK_START;
int docsOnThisPage = Integer.MAX_VALUE;
while (0 < docsOnThisPage) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
index cf12d1d18f5a..d30536826208 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
@@ -27,6 +27,7 @@
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ShardParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.embedded.JettySolrRunner;
import org.apache.solr.util.ServletFixtures;
import org.junit.BeforeClass;
@@ -351,7 +352,9 @@ void doAddDoc(String id) throws Exception {
}
void doRTG(String ids) throws Exception {
- doQuery(ids, "qt", "/get", "ids", ids);
+ final var expectedIds = StrUtils.splitSmart(ids, ",", true);
+ final var request = new QueryRequest("/get", params("ids", ids));
+ doQuery(expectedIds, request);
}
// TODO: refactor some of this stuff into the SolrJ client... it should be easier to use
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplayVsRecovery.java b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplayVsRecovery.java
index f41cfb8a72d2..af90ea36ee3e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplayVsRecovery.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplayVsRecovery.java
@@ -277,7 +277,7 @@ private void assertDocExists(final String clientName, final SolrClient client, f
SolrRequest.METHOD.GET,
"/get",
SolrRequestType.QUERY,
- params("qt", "/get", "id", docId, "_trace", clientName, "distrib", "false"))
+ params("id", docId, "_trace", clientName, "distrib", "false"))
.setRequiresCollection(true))
.process(client, COLLECTION);
diff --git a/solr/core/src/test/org/apache/solr/response/TestJavaBinResponseWriter.java b/solr/core/src/test/org/apache/solr/response/TestJavaBinResponseWriter.java
index 48d990562923..4d12f208415f 100644
--- a/solr/core/src/test/org/apache/solr/response/TestJavaBinResponseWriter.java
+++ b/solr/core/src/test/org/apache/solr/response/TestJavaBinResponseWriter.java
@@ -25,7 +25,6 @@
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.ByteUtils;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.common.util.NamedList;
@@ -72,8 +71,8 @@ public void testUUID() throws Exception {
String s = UUID.randomUUID().toString().toLowerCase(Locale.ROOT);
assertU(adoc("id", "101", "uuid", s));
assertU(commit());
- SolrQueryRequestBase req = lrf.makeRequest("q", "*:*");
- SolrQueryResponse rsp = h.queryAndResponse(req.getParams().get(CommonParams.QT), req);
+ SolrQueryRequest req = withPath("/select", lrf.makeRequest("q", "*:*"));
+ SolrQueryResponse rsp = h.queryAndResponse(req);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
h.getCore().getQueryResponseWriter("javabin").write(baos, req, rsp);
NamedList> res;
diff --git a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformer.java b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformer.java
index b325b6f959e3..2a23681aab64 100644
--- a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformer.java
+++ b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformer.java
@@ -29,7 +29,6 @@
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.common.util.NamedList;
@@ -614,7 +613,7 @@ public void testJustJohnJson() throws Exception {
@SuppressWarnings("unchecked")
@Test
public void testJustJohnJavabin() throws Exception {
- final SolrQueryRequest johnTwoFL = req(johnAndNancyParams);
+ final SolrQueryRequest johnTwoFL = reqWithPath("/select", johnAndNancyParams);
ModifiableSolrParams params = new ModifiableSolrParams(johnTwoFL.getParams());
params.set("q", "name_s:john");
params.set("wt", "javabin");
@@ -626,8 +625,7 @@ public void testJustJohnJavabin() throws Exception {
SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(johnTwoFL, rsp));
- SolrQueryResponse response =
- h.queryAndResponse(johnTwoFL.getParams().get(CommonParams.QT), johnTwoFL);
+ SolrQueryResponse response = h.queryAndResponse(null, johnTwoFL);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
johnTwoFL.getResponseWriter().write(bytes, johnTwoFL, response);
diff --git a/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java b/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java
index 4bf3f14b8b14..1899655c4ce1 100644
--- a/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/EnumFieldTest.java
@@ -681,7 +681,8 @@ public void testFacetEnumSearch() throws Exception {
"//*[@name='buckets']/lst[long[@name='count'][.='1']][str[@name='val'][.='High']]");
try (SolrQueryRequest req =
- req(
+ reqWithPath(
+ "/select",
"fl",
"" + FIELD_NAME,
"q",
@@ -690,7 +691,7 @@ public void testFacetEnumSearch() throws Exception {
jsonFacetParam,
"wt",
"json")) {
- SolrQueryResponse rsp = h.queryAndResponse(req.getParams().get(CommonParams.QT), req);
+ SolrQueryResponse rsp = h.queryAndResponse(req);
List> buckets =
(List>)
((NamedList>) ((NamedList>) rsp.getValues().get("facets")).get("severity"))
diff --git a/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java b/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
index a3ee69b0910c..990875263391 100644
--- a/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
+++ b/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
@@ -58,7 +58,7 @@ public static void beforeTest() throws Exception {
@Test
public void testCacheVetoException() throws Exception {
- String url = getSelectUrl("q", "xyz_ignore_exception:solr", "qt", "standard");
+ String url = getSelectUrl("q", "xyz_ignore_exception:solr");
// We force an exception from Solr. This should emit "no-cache" HTTP headers
ContentResponse response = getHttpClient().GET(url);
assertNotEquals(200, response.getStatus());
diff --git a/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java b/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java
index 3b6a331970bc..1f60da879dc3 100644
--- a/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java
+++ b/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java
@@ -35,7 +35,7 @@ protected String getSelectUrl(String... params) {
sb.append("/select?");
if (params.length == 0) {
- sb.append("q=solr&qt=standard");
+ sb.append("q=solr");
} else {
for (int i = 0; i < params.length / 2; i++) {
if (i > 0) sb.append("&");
diff --git a/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java b/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
index f1e16e46dc46..eb834a180e96 100644
--- a/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
+++ b/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
@@ -111,7 +111,7 @@ public void testUrlParamParsing() {
@Test
public void testStandardParseParamsAndFillStreams() throws Exception {
- final String getParams = "qt=%C3%BC&dup=foo", postParams = "q=hello&d%75p=bar";
+ final String getParams = "misc=%C3%BC&dup=foo", postParams = "q=hello&d%75p=bar";
final byte[] postBytes = postParams.getBytes(StandardCharsets.US_ASCII);
// Set up the expected behavior
@@ -137,7 +137,7 @@ public void testStandardParseParamsAndFillStreams() throws Exception {
SolrParams p = standard.parseParamsAndFillStreams(request, new ArrayList());
assertEquals("contentType: " + contentType, "hello", p.get("q"));
- assertEquals("contentType: " + contentType, "\u00FC", p.get("qt"));
+ assertEquals("contentType: " + contentType, "\u00FC", p.get("misc"));
assertArrayEquals(
"contentType: " + contentType, new String[] {"foo", "bar"}, p.getParams("dup"));
@@ -202,8 +202,8 @@ public int read() throws IOException {
@Test
public void testStandardParseParamsAndFillStreamsISO88591() throws Exception {
- final String getParams = "qt=%FC&dup=foo&ie=iso-8859-1&dup=%FC",
- postParams = "qt2=%FC&q=hello&d%75p=bar";
+ final String getParams = "misc=%FC&dup=foo&ie=iso-8859-1&dup=%FC",
+ postParams = "misc2=%FC&q=hello&d%75p=bar";
final byte[] postBytes = postParams.getBytes(StandardCharsets.US_ASCII);
final String contentType = "application/x-www-form-urlencoded; charset=iso-8859-1";
@@ -221,8 +221,8 @@ public void testStandardParseParamsAndFillStreamsISO88591() throws Exception {
SolrParams p = standard.parseParamsAndFillStreams(request, new ArrayList());
assertEquals("contentType: " + contentType, "hello", p.get("q"));
- assertEquals("contentType: " + contentType, "\u00FC", p.get("qt"));
- assertEquals("contentType: " + contentType, "\u00FC", p.get("qt2"));
+ assertEquals("contentType: " + contentType, "\u00FC", p.get("misc"));
+ assertEquals("contentType: " + contentType, "\u00FC", p.get("misc2"));
assertArrayEquals(
"contentType: " + contentType, new String[] {"foo", "\u00FC", "bar"}, p.getParams("dup"));
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
index 20ca82790836..56227abba3eb 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
@@ -71,6 +71,7 @@
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.RequestStatusState;
+import org.apache.solr.client.solrj.response.SimpleSolrResponse;
import org.apache.solr.cloud.ZkController.NotInClusterStateException;
import org.apache.solr.cloud.api.collections.CollectionHandlingUtils;
import org.apache.solr.common.SolrDocument;
@@ -1409,10 +1410,10 @@ protected void checkQueries() throws Exception {
handle.put("response", UNORDERED); // get?ids=a,b,c requests are unordered
String ids = "987654";
for (int i = 0; i < 20; i++) {
- query("qt", "/get", "id", Integer.toString(i));
- query("qt", "/get", "ids", Integer.toString(i));
+ query("/get", params("id", Integer.toString(i)));
+ query("/get", params("ids", Integer.toString(i)));
ids = ids + ',' + Integer.toString(i);
- query("qt", "/get", "ids", ids);
+ query("/get", params("ids", ids));
}
handle.remove("response");
@@ -2179,6 +2180,18 @@ void doQuery(String expectedDocs, String... queryParams) throws Exception {
assertEquals(expectedIds, obtainedIds);
}
+ void doQuery(Collection expectedIds, QueryRequest request) throws Exception {
+ Set expectedIdSet = new HashSet<>(expectedIds);
+
+ QueryResponse rsp = request.process(cloudClient);
+ Set obtainedIds = new HashSet<>();
+ for (SolrDocument doc : rsp.getResults()) {
+ obtainedIds.add((String) doc.get("id"));
+ }
+
+ assertEquals(expectedIdSet, obtainedIds);
+ }
+
@Override
public void distribTearDown() throws Exception {
try {
@@ -3002,10 +3015,12 @@ protected long getIndexVersion(Replica replica) throws IOException {
.withDefaultCollection(replica.getCoreName())
.build()) {
ModifiableSolrParams params = new ModifiableSolrParams();
- params.set("qt", "/replication");
params.set(ReplicationHandler.COMMAND, ReplicationHandler.CMD_SHOW_COMMITS);
try {
- QueryResponse response = client.query(params);
+ SimpleSolrResponse response =
+ new GenericSolrRequest(METHOD.GET, "/replication", params)
+ .setRequiresCollection(true)
+ .process(client);
@SuppressWarnings("unchecked")
List> commits =
(List>)
@@ -3052,10 +3067,12 @@ protected void logReplicationDetails(Replica replica, StringBuilder builder) thr
.withDefaultCollection(replica.getCoreName())
.build()) {
ModifiableSolrParams params = new ModifiableSolrParams();
- params.set("qt", "/replication");
params.set(ReplicationHandler.COMMAND, ReplicationHandler.CMD_DETAILS);
try {
- QueryResponse response = client.query(params);
+ SimpleSolrResponse response =
+ new GenericSolrRequest(METHOD.GET, "/replication", params)
+ .setRequiresCollection(true)
+ .process(client);
builder.append(
String.format(
Locale.ROOT,
diff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
index f0808526c0da..f76dcc9c3b0b 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
@@ -16,6 +16,8 @@
*/
package org.apache.solr.util;
+import static org.apache.solr.SolrTestCaseJ4.withPath;
+
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
@@ -343,13 +345,25 @@ public String query(String handler, SolrQueryRequest req) throws Exception {
/**
* It is the users responsibility to close the request object when done with it. This method does
* not set/clear SolrRequestInfo
+ *
+ * @deprecated use {@link #queryAndResponse(SolrQueryRequest)} instead, ensuring that
+ * SolrQueryRequest has a valid path
*/
+ @Deprecated
public SolrQueryResponse queryAndResponse(String handler, SolrQueryRequest req) throws Exception {
+ return queryAndResponse(withPath(handler, req));
+ }
+
+ /**
+ * It is the users responsibility to close the request object when done with it. This method does
+ * not set/clear SolrRequestInfo
+ */
+ public SolrQueryResponse queryAndResponse(SolrQueryRequest req) throws Exception {
try (var mdcSnap = MDCSnapshot.create();
SolrCore core = getCoreInc()) {
assert null != mdcSnap; // prevent compiler warning of unused var
SolrQueryResponse rsp = new SolrQueryResponse();
- core.execute(core.getRequestHandler(handler), req, rsp);
+ core.execute(core.getRequestHandler(req.getPath()), req, rsp);
if (rsp.getException() != null) {
throw rsp.getException();
}