From 3646fe3b486ad28c97a1aa6a8f96e8288c4c11c6 Mon Sep 17 00:00:00 2001 From: r4mercur Date: Fri, 25 Jul 2025 18:32:24 +0200 Subject: [PATCH 01/10] SOLR-17715: Remove qt parameter from the final parameters sent to server --- .../client/solrj/request/QueryRequest.java | 8 ++ .../solrj/request/QueryRequestQtTest.java | 79 +++++++++++++++++++ .../client/solrj/util/ClientUtilsTest.java | 37 +++++++++ 3 files changed, 124 insertions(+) create mode 100644 solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java index de3cdd78b9ae..5711872b8fbe 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java @@ -19,6 +19,7 @@ import java.util.Objects; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; @@ -67,6 +68,13 @@ protected QueryResponse createResponse(NamedList namedList) { @Override public SolrParams getParams() { + // Remove qt parameter from the final parameters sent to server + String qt = query.get(CommonParams.QT); + if (qt != null) { + ModifiableSolrParams params = new ModifiableSolrParams(query); + params.remove(CommonParams.QT); + return params; + } return query; } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java new file mode 100644 index 000000000000..645e76c8316d --- /dev/null +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java @@ -0,0 +1,79 @@ +/* + * 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. + */ +package org.apache.solr.client.solrj.request; + +import org.apache.solr.SolrTestCase; +import org.apache.solr.client.solrj.SolrQuery; +import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.params.SolrParams; +import org.junit.Test; + +/** + * Test that verifies SOLR-17715: qt parameter should not be sent to Solr server + */ +public class QueryRequestQtTest extends SolrTestCase { + + @Test + public void testQtParameterRemovedFromRequest() { + SolrQuery query = new SolrQuery("*:*"); + query.setRequestHandler("/custom"); + + QueryRequest request = new QueryRequest(query); + + // The path should be extracted from qt + assertEquals("/custom", request.getPath()); + + // But qt should not be in the final parameters + SolrParams params = request.getParams(); + assertNull("qt parameter should be removed from request params", + params.get(CommonParams.QT)); + assertEquals("*:*", params.get(CommonParams.Q)); + } + + @Test + public void testQtParameterWithoutSlashUsesSelect() { + SolrQuery query = new SolrQuery("*:*"); + query.setRequestHandler("custom"); // no leading slash + + QueryRequest request = new QueryRequest(query); + + // Should default to /select when qt doesn't start with / + assertEquals("/select", request.getPath()); + + // qt should still be removed from parameters + SolrParams params = request.getParams(); + assertNull("qt parameter should be removed from request params", + params.get(CommonParams.QT)); + } + + @Test + public void testNoQtParameter() { + SolrQuery query = new SolrQuery("*:*"); + // Don't set any request handler + + QueryRequest request = new QueryRequest(query); + + // Should default to /select + assertEquals("/select", request.getPath()); + + // Should not have qt parameter + SolrParams params = request.getParams(); + assertNull("qt parameter should not be present", + params.get(CommonParams.QT)); + assertEquals("*:*", params.get(CommonParams.Q)); + } +} diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java index e3fb435eca5b..b1b3656c4a19 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java @@ -17,11 +17,14 @@ package org.apache.solr.client.solrj.util; import org.apache.solr.SolrTestCase; +import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.impl.XMLRequestWriter; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.HealthCheckRequest; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.UpdateRequest; +import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.params.SolrParams; import org.junit.Test; /** @@ -79,4 +82,38 @@ public void testUrlBuilding() throws Exception { assertEquals("http://localhost:8983/solr/admin/info/health", url); } } + + @Test + public void testQueryRequestQtParameterRemoval() { + // Test SOLR-17715: qt parameter should not be sent to Solr server + SolrQuery query = new SolrQuery("*:*"); + query.setRequestHandler("/custom"); + + QueryRequest request = new QueryRequest(query); + + // The path should be extracted from qt + assertEquals("/custom", request.getPath()); + + // But qt should not be in the final parameters + SolrParams params = request.getParams(); + assertNull("qt parameter should be removed from request params", + params.get(CommonParams.QT)); + assertEquals("*:*", params.get(CommonParams.Q)); + } + + @Test + public void testQueryRequestQtParameterWithoutSlash() { + SolrQuery query = new SolrQuery("*:*"); + query.setRequestHandler("custom"); // no leading slash + + QueryRequest request = new QueryRequest(query); + + // Should default to /select when qt doesn't start with / + assertEquals("/select", request.getPath()); + + // qt should still be removed from parameters + SolrParams params = request.getParams(); + assertNull("qt parameter should be removed from request params", + params.get(CommonParams.QT)); + } } From 4aff3f25b7ddb2883ccd5811c8daa88522a9472b Mon Sep 17 00:00:00 2001 From: r4mercur Date: Mon, 4 May 2026 20:12:33 +0200 Subject: [PATCH 02/10] SOLR-17715: Remove qt parameter from QueryRequest and add test cases --- .../client/solrj/request/QueryRequest.java | 46 +++++------ ...questQtTest.java => QueryRequestTest.java} | 77 +++++++++---------- .../client/solrj/util/ClientUtilsTest.java | 34 -------- 3 files changed, 62 insertions(+), 95 deletions(-) rename solr/solrj/src/test/org/apache/solr/client/solrj/request/{QueryRequestQtTest.java => QueryRequestTest.java} (53%) diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java index 5711872b8fbe..72986ccc1a27 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java @@ -31,31 +31,40 @@ public class QueryRequest extends CollectionRequiringSolrRequest private final SolrParams query; public QueryRequest() { - super(METHOD.GET, null, SolrRequestType.QUERY); + super(METHOD.GET, "/select", SolrRequestType.QUERY); query = SolrParams.of(); } public QueryRequest(SolrParams q) { - super(METHOD.GET, null, SolrRequestType.QUERY); - query = Objects.requireNonNull(q); + super(METHOD.GET, pathFromParams(Objects.requireNonNull(q)), SolrRequestType.QUERY); + query = paramsWithoutQt(q); } public QueryRequest(SolrParams q, METHOD method) { - super(method, null, SolrRequestType.QUERY); + super(method, pathFromParams(Objects.requireNonNull(q)), SolrRequestType.QUERY); + query = paramsWithoutQt(q); + } + + public QueryRequest(String path, SolrParams q) { + super(METHOD.GET, Objects.requireNonNull(path), SolrRequestType.QUERY); query = Objects.requireNonNull(q); } - /** Use the params 'QT' parameter if it exists */ - @Override - public String getPath() { - String qt = query.get(CommonParams.QT); - if (qt == null) { - qt = super.getPath(); - } - if (qt != null && qt.startsWith("/")) { - return qt; - } - return "/select"; + public QueryRequest(String path, SolrParams q, METHOD method) { + super(method, Objects.requireNonNull(path), SolrRequestType.QUERY); + query = Objects.requireNonNull(q); + } + + private static String pathFromParams(SolrParams q) { + String qt = q.get(CommonParams.QT); + return (qt != null && qt.startsWith("/")) ? qt : "/select"; + } + + private static SolrParams paramsWithoutQt(SolrParams q) { + if (q.get(CommonParams.QT) == null) return q; + ModifiableSolrParams params = new ModifiableSolrParams(q); + params.remove(CommonParams.QT); + return params; } // --------------------------------------------------------------------------------- @@ -68,13 +77,6 @@ protected QueryResponse createResponse(NamedList namedList) { @Override public SolrParams getParams() { - // Remove qt parameter from the final parameters sent to server - String qt = query.get(CommonParams.QT); - if (qt != null) { - ModifiableSolrParams params = new ModifiableSolrParams(query); - params.remove(CommonParams.QT); - return params; - } return query; } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java similarity index 53% rename from solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java rename to solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java index 645e76c8316d..f97600f935e8 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java @@ -18,62 +18,61 @@ import org.apache.solr.SolrTestCase; import org.apache.solr.client.solrj.SolrQuery; -import org.apache.solr.common.params.CommonParams; -import org.apache.solr.common.params.SolrParams; +import org.apache.solr.client.solrj.SolrRequest; import org.junit.Test; -/** - * Test that verifies SOLR-17715: qt parameter should not be sent to Solr server - */ -public class QueryRequestQtTest extends SolrTestCase { +public class QueryRequestTest extends SolrTestCase { @Test - public void testQtParameterRemovedFromRequest() { + public void testQtWithSlashBecomesPath() { SolrQuery query = new SolrQuery("*:*"); query.setRequestHandler("/custom"); - + QueryRequest request = new QueryRequest(query); - - // The path should be extracted from qt + assertEquals("/custom", request.getPath()); - - // But qt should not be in the final parameters - SolrParams params = request.getParams(); - assertNull("qt parameter should be removed from request params", - params.get(CommonParams.QT)); - assertEquals("*:*", params.get(CommonParams.Q)); + assertNull("qt must not be sent to server", request.getParams().get("qt")); + assertEquals("*:*", request.getParams().get("q")); } - + @Test - public void testQtParameterWithoutSlashUsesSelect() { + public void testQtWithoutSlashDefaultsToSelect() { SolrQuery query = new SolrQuery("*:*"); query.setRequestHandler("custom"); // no leading slash - + QueryRequest request = new QueryRequest(query); - - // Should default to /select when qt doesn't start with / + assertEquals("/select", request.getPath()); - - // qt should still be removed from parameters - SolrParams params = request.getParams(); - assertNull("qt parameter should be removed from request params", - params.get(CommonParams.QT)); + assertNull("qt must not be sent to server", request.getParams().get("qt")); } - + @Test - public void testNoQtParameter() { + public void testNoQtDefaultsToSelect() { SolrQuery query = new SolrQuery("*:*"); - // Don't set any request handler - + QueryRequest request = new QueryRequest(query); - - // Should default to /select + assertEquals("/select", request.getPath()); - - // Should not have qt parameter - SolrParams params = request.getParams(); - assertNull("qt parameter should not be present", - params.get(CommonParams.QT)); - assertEquals("*:*", params.get(CommonParams.Q)); + assertNull(request.getParams().get("qt")); + } + + @Test + public void testExplicitPath() { + SolrQuery query = new SolrQuery("*:*"); + QueryRequest request = new QueryRequest("/custom", query); + + assertEquals("/custom", request.getPath()); + assertNull("qt must not be present", request.getParams().get("qt")); + assertEquals("*:*", request.getParams().get("q")); + } + + @Test + public void testExplicitPathWithMethod() { + SolrQuery query = new SolrQuery("*:*"); + QueryRequest request = new QueryRequest("/spell", query, SolrRequest.METHOD.POST); + + assertEquals("/spell", request.getPath()); + assertEquals(SolrRequest.METHOD.POST, request.getMethod()); + assertNull(request.getParams().get("qt")); } -} +} \ No newline at end of file diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java index b1b3656c4a19..ef377b12c83d 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java @@ -82,38 +82,4 @@ public void testUrlBuilding() throws Exception { assertEquals("http://localhost:8983/solr/admin/info/health", url); } } - - @Test - public void testQueryRequestQtParameterRemoval() { - // Test SOLR-17715: qt parameter should not be sent to Solr server - SolrQuery query = new SolrQuery("*:*"); - query.setRequestHandler("/custom"); - - QueryRequest request = new QueryRequest(query); - - // The path should be extracted from qt - assertEquals("/custom", request.getPath()); - - // But qt should not be in the final parameters - SolrParams params = request.getParams(); - assertNull("qt parameter should be removed from request params", - params.get(CommonParams.QT)); - assertEquals("*:*", params.get(CommonParams.Q)); - } - - @Test - public void testQueryRequestQtParameterWithoutSlash() { - SolrQuery query = new SolrQuery("*:*"); - query.setRequestHandler("custom"); // no leading slash - - QueryRequest request = new QueryRequest(query); - - // Should default to /select when qt doesn't start with / - assertEquals("/select", request.getPath()); - - // qt should still be removed from parameters - SolrParams params = request.getParams(); - assertNull("qt parameter should be removed from request params", - params.get(CommonParams.QT)); - } } From 5dcad7bb6092a76082e6e7951e71b52cb44fe699 Mon Sep 17 00:00:00 2001 From: r4mercur Date: Fri, 25 Jul 2025 18:32:24 +0200 Subject: [PATCH 03/10] SOLR-17715: Remove qt parameter from the final parameters sent to server --- .../client/solrj/request/QueryRequest.java | 8 ++ .../solrj/request/QueryRequestQtTest.java | 79 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java index 04b4d4e3a548..9c89092c8966 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java @@ -19,6 +19,7 @@ import java.util.Objects; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; @@ -70,6 +71,13 @@ protected QueryResponse createResponse(NamedList namedList) { @Override public SolrParams getParams() { + // Remove qt parameter from the final parameters sent to server + String qt = query.get(CommonParams.QT); + if (qt != null) { + ModifiableSolrParams params = new ModifiableSolrParams(query); + params.remove(CommonParams.QT); + return params; + } return query; } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java new file mode 100644 index 000000000000..645e76c8316d --- /dev/null +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java @@ -0,0 +1,79 @@ +/* + * 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. + */ +package org.apache.solr.client.solrj.request; + +import org.apache.solr.SolrTestCase; +import org.apache.solr.client.solrj.SolrQuery; +import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.params.SolrParams; +import org.junit.Test; + +/** + * Test that verifies SOLR-17715: qt parameter should not be sent to Solr server + */ +public class QueryRequestQtTest extends SolrTestCase { + + @Test + public void testQtParameterRemovedFromRequest() { + SolrQuery query = new SolrQuery("*:*"); + query.setRequestHandler("/custom"); + + QueryRequest request = new QueryRequest(query); + + // The path should be extracted from qt + assertEquals("/custom", request.getPath()); + + // But qt should not be in the final parameters + SolrParams params = request.getParams(); + assertNull("qt parameter should be removed from request params", + params.get(CommonParams.QT)); + assertEquals("*:*", params.get(CommonParams.Q)); + } + + @Test + public void testQtParameterWithoutSlashUsesSelect() { + SolrQuery query = new SolrQuery("*:*"); + query.setRequestHandler("custom"); // no leading slash + + QueryRequest request = new QueryRequest(query); + + // Should default to /select when qt doesn't start with / + assertEquals("/select", request.getPath()); + + // qt should still be removed from parameters + SolrParams params = request.getParams(); + assertNull("qt parameter should be removed from request params", + params.get(CommonParams.QT)); + } + + @Test + public void testNoQtParameter() { + SolrQuery query = new SolrQuery("*:*"); + // Don't set any request handler + + QueryRequest request = new QueryRequest(query); + + // Should default to /select + assertEquals("/select", request.getPath()); + + // Should not have qt parameter + SolrParams params = request.getParams(); + assertNull("qt parameter should not be present", + params.get(CommonParams.QT)); + assertEquals("*:*", params.get(CommonParams.Q)); + } +} From a74906702485d2574c17012daa4718098ae4e511 Mon Sep 17 00:00:00 2001 From: r4mercur Date: Mon, 4 May 2026 20:12:33 +0200 Subject: [PATCH 04/10] SOLR-17715: Remove qt parameter from QueryRequest and add test cases --- .../client/solrj/request/QueryRequest.java | 46 +++++------ ...questQtTest.java => QueryRequestTest.java} | 77 +++++++++---------- 2 files changed, 62 insertions(+), 61 deletions(-) rename solr/solrj/src/test/org/apache/solr/client/solrj/request/{QueryRequestQtTest.java => QueryRequestTest.java} (53%) diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java index 9c89092c8966..2ccf8d328b9f 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java @@ -34,31 +34,40 @@ public class QueryRequest extends CollectionRequiringSolrRequest private final SolrParams query; public QueryRequest() { - super(METHOD.GET, null, SolrRequestType.QUERY); + super(METHOD.GET, "/select", SolrRequestType.QUERY); query = SolrParams.of(); } public QueryRequest(SolrParams q) { - super(METHOD.GET, null, SolrRequestType.QUERY); - query = Objects.requireNonNull(q); + super(METHOD.GET, pathFromParams(Objects.requireNonNull(q)), SolrRequestType.QUERY); + query = paramsWithoutQt(q); } public QueryRequest(SolrParams q, METHOD method) { - super(method, null, SolrRequestType.QUERY); + super(method, pathFromParams(Objects.requireNonNull(q)), SolrRequestType.QUERY); + query = paramsWithoutQt(q); + } + + public QueryRequest(String path, SolrParams q) { + super(METHOD.GET, Objects.requireNonNull(path), SolrRequestType.QUERY); query = Objects.requireNonNull(q); } - /** Use the params 'QT' parameter if it exists */ - @Override - public String getPath() { - String qt = query.get(CommonParams.QT); - if (qt == null) { - qt = super.getPath(); - } - if (qt != null && qt.startsWith("/")) { - return qt; - } - return "/select"; + public QueryRequest(String path, SolrParams q, METHOD method) { + super(method, Objects.requireNonNull(path), SolrRequestType.QUERY); + query = Objects.requireNonNull(q); + } + + private static String pathFromParams(SolrParams q) { + String qt = q.get(CommonParams.QT); + return (qt != null && qt.startsWith("/")) ? qt : "/select"; + } + + private static SolrParams paramsWithoutQt(SolrParams q) { + if (q.get(CommonParams.QT) == null) return q; + ModifiableSolrParams params = new ModifiableSolrParams(q); + params.remove(CommonParams.QT); + return params; } // --------------------------------------------------------------------------------- @@ -71,13 +80,6 @@ protected QueryResponse createResponse(NamedList namedList) { @Override public SolrParams getParams() { - // Remove qt parameter from the final parameters sent to server - String qt = query.get(CommonParams.QT); - if (qt != null) { - ModifiableSolrParams params = new ModifiableSolrParams(query); - params.remove(CommonParams.QT); - return params; - } return query; } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java similarity index 53% rename from solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java rename to solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java index 645e76c8316d..f97600f935e8 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestQtTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java @@ -18,62 +18,61 @@ import org.apache.solr.SolrTestCase; import org.apache.solr.client.solrj.SolrQuery; -import org.apache.solr.common.params.CommonParams; -import org.apache.solr.common.params.SolrParams; +import org.apache.solr.client.solrj.SolrRequest; import org.junit.Test; -/** - * Test that verifies SOLR-17715: qt parameter should not be sent to Solr server - */ -public class QueryRequestQtTest extends SolrTestCase { +public class QueryRequestTest extends SolrTestCase { @Test - public void testQtParameterRemovedFromRequest() { + public void testQtWithSlashBecomesPath() { SolrQuery query = new SolrQuery("*:*"); query.setRequestHandler("/custom"); - + QueryRequest request = new QueryRequest(query); - - // The path should be extracted from qt + assertEquals("/custom", request.getPath()); - - // But qt should not be in the final parameters - SolrParams params = request.getParams(); - assertNull("qt parameter should be removed from request params", - params.get(CommonParams.QT)); - assertEquals("*:*", params.get(CommonParams.Q)); + assertNull("qt must not be sent to server", request.getParams().get("qt")); + assertEquals("*:*", request.getParams().get("q")); } - + @Test - public void testQtParameterWithoutSlashUsesSelect() { + public void testQtWithoutSlashDefaultsToSelect() { SolrQuery query = new SolrQuery("*:*"); query.setRequestHandler("custom"); // no leading slash - + QueryRequest request = new QueryRequest(query); - - // Should default to /select when qt doesn't start with / + assertEquals("/select", request.getPath()); - - // qt should still be removed from parameters - SolrParams params = request.getParams(); - assertNull("qt parameter should be removed from request params", - params.get(CommonParams.QT)); + assertNull("qt must not be sent to server", request.getParams().get("qt")); } - + @Test - public void testNoQtParameter() { + public void testNoQtDefaultsToSelect() { SolrQuery query = new SolrQuery("*:*"); - // Don't set any request handler - + QueryRequest request = new QueryRequest(query); - - // Should default to /select + assertEquals("/select", request.getPath()); - - // Should not have qt parameter - SolrParams params = request.getParams(); - assertNull("qt parameter should not be present", - params.get(CommonParams.QT)); - assertEquals("*:*", params.get(CommonParams.Q)); + assertNull(request.getParams().get("qt")); + } + + @Test + public void testExplicitPath() { + SolrQuery query = new SolrQuery("*:*"); + QueryRequest request = new QueryRequest("/custom", query); + + assertEquals("/custom", request.getPath()); + assertNull("qt must not be present", request.getParams().get("qt")); + assertEquals("*:*", request.getParams().get("q")); + } + + @Test + public void testExplicitPathWithMethod() { + SolrQuery query = new SolrQuery("*:*"); + QueryRequest request = new QueryRequest("/spell", query, SolrRequest.METHOD.POST); + + assertEquals("/spell", request.getPath()); + assertEquals(SolrRequest.METHOD.POST, request.getMethod()); + assertNull(request.getParams().get("qt")); } -} +} \ No newline at end of file From 9144b24e083e98d39a4748f27f56d0ac47ae77fb Mon Sep 17 00:00:00 2001 From: r4mercur Date: Mon, 4 May 2026 20:54:14 +0200 Subject: [PATCH 05/10] SOLR-17715: Gradle check adjustments --- .../client/solrj/request/QueryRequestTest.java | 15 +++++++++------ .../solr/client/solrj/util/ClientUtilsTest.java | 3 --- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java index f97600f935e8..35340cd3d2e4 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java @@ -31,23 +31,25 @@ public void testQtWithSlashBecomesPath() { QueryRequest request = new QueryRequest(query); assertEquals("/custom", request.getPath()); - assertNull("qt must not be sent to server", request.getParams().get("qt")); + assertNull("qt parameter should be removed from request params", + request.getParams().get("qt")); assertEquals("*:*", request.getParams().get("q")); } @Test public void testQtWithoutSlashDefaultsToSelect() { SolrQuery query = new SolrQuery("*:*"); - query.setRequestHandler("custom"); // no leading slash + query.setRequestHandler("custom"); QueryRequest request = new QueryRequest(query); assertEquals("/select", request.getPath()); - assertNull("qt must not be sent to server", request.getParams().get("qt")); + assertNull("qt parameter shouldn't be sent to server", + request.getParams().get("qt")); } @Test - public void testNoQtDefaultsToSelect() { + public void testDefaultPathToSelect() { SolrQuery query = new SolrQuery("*:*"); QueryRequest request = new QueryRequest(query); @@ -62,7 +64,8 @@ public void testExplicitPath() { QueryRequest request = new QueryRequest("/custom", query); assertEquals("/custom", request.getPath()); - assertNull("qt must not be present", request.getParams().get("qt")); + assertNull("qt parameter must not be present", + request.getParams().get("qt")); assertEquals("*:*", request.getParams().get("q")); } @@ -75,4 +78,4 @@ public void testExplicitPathWithMethod() { assertEquals(SolrRequest.METHOD.POST, request.getMethod()); assertNull(request.getParams().get("qt")); } -} \ No newline at end of file +} diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java index ef377b12c83d..e3fb435eca5b 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java @@ -17,14 +17,11 @@ package org.apache.solr.client.solrj.util; import org.apache.solr.SolrTestCase; -import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.impl.XMLRequestWriter; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.HealthCheckRequest; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.UpdateRequest; -import org.apache.solr.common.params.CommonParams; -import org.apache.solr.common.params.SolrParams; import org.junit.Test; /** From 8d4dc49a6209a77b407edd103745f2accd89eb3a Mon Sep 17 00:00:00 2001 From: r4mercur Date: Mon, 4 May 2026 20:56:05 +0200 Subject: [PATCH 06/10] SOLR-17715: Remove changes from ClientUtilsTest --- .../test/org/apache/solr/client/solrj/util/ClientUtilsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java index e3fb435eca5b..2b17ed41386a 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/util/ClientUtilsTest.java @@ -17,11 +17,11 @@ package org.apache.solr.client.solrj.util; import org.apache.solr.SolrTestCase; -import org.apache.solr.client.solrj.impl.XMLRequestWriter; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.HealthCheckRequest; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.UpdateRequest; +import org.apache.solr.client.solrj.request.XMLRequestWriter; import org.junit.Test; /** From e553f6ee3085069f944a2b7dc9a958a91295e2e4 Mon Sep 17 00:00:00 2001 From: r4mercur Date: Mon, 4 May 2026 21:15:26 +0200 Subject: [PATCH 07/10] SOLR-17715: Fix QueryRequestTest.java and Gradle tidy --- .../solr/client/solrj/request/QueryRequestTest.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java index 35340cd3d2e4..dfc314c2e8c8 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/QueryRequestTest.java @@ -17,7 +17,6 @@ package org.apache.solr.client.solrj.request; import org.apache.solr.SolrTestCase; -import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrRequest; import org.junit.Test; @@ -31,8 +30,7 @@ public void testQtWithSlashBecomesPath() { QueryRequest request = new QueryRequest(query); assertEquals("/custom", request.getPath()); - assertNull("qt parameter should be removed from request params", - request.getParams().get("qt")); + assertNull("qt parameter should be removed from request params", request.getParams().get("qt")); assertEquals("*:*", request.getParams().get("q")); } @@ -44,8 +42,7 @@ public void testQtWithoutSlashDefaultsToSelect() { QueryRequest request = new QueryRequest(query); assertEquals("/select", request.getPath()); - assertNull("qt parameter shouldn't be sent to server", - request.getParams().get("qt")); + assertNull("qt parameter shouldn't be sent to server", request.getParams().get("qt")); } @Test @@ -64,8 +61,7 @@ public void testExplicitPath() { QueryRequest request = new QueryRequest("/custom", query); assertEquals("/custom", request.getPath()); - assertNull("qt parameter must not be present", - request.getParams().get("qt")); + assertNull("qt parameter must not be present", request.getParams().get("qt")); assertEquals("*:*", request.getParams().get("q")); } From 10b7faab821368664f2e42809e078ed623cb0adb Mon Sep 17 00:00:00 2001 From: r4mercur Date: Mon, 4 May 2026 21:55:08 +0200 Subject: [PATCH 08/10] SOLR-17715: Add changelog entry for changes --- .../SOLR-17715-remove-qt-param-from-queryrequest.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml diff --git a/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml b/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml new file mode 100644 index 000000000000..b00b63317268 --- /dev/null +++ b/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml @@ -0,0 +1,12 @@ +# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc +title: > + QueryRequest.java in SolrJ no longer sends the 'qt' parameter to the server. +type: changed # added, changed, fixed, deprecated, removed, dependency_update, security, other +authors: + - name: r4mercur + nick: r4mercur +links: + - name: SOLR-17715 + url: https://issues.apache.org/jira/browse/SOLR-17715 + - name: PR#3441 + url: https://github.com/apache/solr/pull/3441 From d9f505fae82a8652c49e07829de187f26b65d108 Mon Sep 17 00:00:00 2001 From: r4mercur <43001217+r4mercur@users.noreply.github.com> Date: Tue, 5 May 2026 10:08:53 +0200 Subject: [PATCH 09/10] Update PR link in changelog for SOLR-17715 --- .../unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml b/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml index b00b63317268..25682acaf518 100644 --- a/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml +++ b/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml @@ -9,4 +9,4 @@ links: - name: SOLR-17715 url: https://issues.apache.org/jira/browse/SOLR-17715 - name: PR#3441 - url: https://github.com/apache/solr/pull/3441 + url: https://github.com/apache/solr/pull/4397 From 30d206f6d84f23120a71e44a17c3fdbbea6dad59 Mon Sep 17 00:00:00 2001 From: r4mercur <43001217+r4mercur@users.noreply.github.com> Date: Tue, 5 May 2026 10:10:24 +0200 Subject: [PATCH 10/10] SOLR-17715: Update PR link in changelog for SOLR-17715 --- .../unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml b/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml index 25682acaf518..71de6bf86459 100644 --- a/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml +++ b/changelog/unreleased/SOLR-17715-remove-qt-param-from-queryrequest.yml @@ -8,5 +8,5 @@ authors: links: - name: SOLR-17715 url: https://issues.apache.org/jira/browse/SOLR-17715 - - name: PR#3441 + - name: PR#4397 url: https://github.com/apache/solr/pull/4397