You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2026/09/09 17:56:04 UTC
(solr) 04/06: HttpSolrClient add withTheseParamNamesInTheUrl defaults (#4871)
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 6f27cf39a58c95a32aa5d67b29ab0c16058532ca
Author: David Smiley <ds...@apache.org>
AuthorDate: Wed Sep 9 11:11:19 2026 -0400
HttpSolrClient add withTheseParamNamesInTheUrl defaults (#4871)
HttpSolrClient impls now sends certain interesting request parameters in the URL query string when a POST of parameters is submitted. In other words, withTheseParamNamesInTheUrl now has a default set. This improves observability, particularly for distributed search & admin commands.
Backport adapted for the 9x client hierarchy: the default set and its
application land in HttpSolrClientBase (shared by Http2SolrClient /
HttpJdkSolrClient / CloudHttp2SolrClient / LBHttp2SolrClient); on main these
were merged into the HttpSolrClient base by SOLR-17968 (#3829), which is not on
branch_9x. The deprecated Apache-HttpClient HttpSolrClient is left unchanged.
(cherry picked from commit 5c3ae79fbde74ad67e22a11b520d3fd479cdbc50)
Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BtZLUe51kwP5rcZyNgE9hG
---
.../PR#4871-httpSolrClientDefaultUrlParams.yml | 9 +++++++
.../solr/client/solrj/impl/HttpSolrClientBase.java | 28 ++++++++++++++++++----
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/changelog/unreleased/PR#4871-httpSolrClientDefaultUrlParams.yml b/changelog/unreleased/PR#4871-httpSolrClientDefaultUrlParams.yml
new file mode 100644
index 00000000000..7dfcae61bdf
--- /dev/null
+++ b/changelog/unreleased/PR#4871-httpSolrClientDefaultUrlParams.yml
@@ -0,0 +1,9 @@
+title: >
+ HttpSolrClient impls now sends certain interesting request parameters in the URL query string when a POST of parameters is submitted. In other words, withTheseParamNamesInTheUrl now has a default set.
+ This improves observability, particularly for distributed search & admin commands.
+type: changed
+authors:
+ - name: David Smiley
+links:
+ - name: PR#4871
+ url: https://github.com/apache/solr/pull/4871
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBase.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBase.java
index 9893f6ce7fd..ad302706d82 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBase.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBase.java
@@ -31,6 +31,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
@@ -44,8 +45,12 @@ import org.apache.solr.client.solrj.util.AsyncListener;
import org.apache.solr.client.solrj.util.Cancellable;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CollectionAdminParams;
+import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.Utils;
@@ -56,6 +61,23 @@ public abstract class HttpSolrClientBase extends SolrClient {
protected static final Charset FALLBACK_CHARSET = StandardCharsets.UTF_8;
private static final List<String> errPath = Arrays.asList("metadata", "error-class");
+ /**
+ * See {@link #getUrlParamNames()}. Default set are interesting for routing or fundamental request
+ * purpose
+ */
+ public static final Set<String> DEFAULT_URL_PARAM_NAMES =
+ Set.of(
+ CoreAdminParams.ACTION,
+ CommonAdminParams.ASYNC,
+ CollectionAdminParams.COLLECTION,
+ "name", // core/collection name
+ "command", // e.g. for replication
+ ShardParams.IS_SHARD,
+ CommonParams.DISTRIB,
+ ShardParams._ROUTE_,
+ ShardParams.SHARDS_PREFERENCE,
+ ShardParams.SHARDS_PURPOSE);
+
/** The URL of the Solr server. */
protected final String serverBaseUrl;
@@ -94,11 +116,7 @@ public abstract class HttpSolrClientBase extends SolrClient {
this.parser = builder.responseParser;
}
this.defaultCollection = builder.defaultCollection;
- if (builder.urlParamNames != null) {
- this.urlParamNames = builder.urlParamNames;
- } else {
- this.urlParamNames = Set.of();
- }
+ this.urlParamNames = Objects.requireNonNullElse(builder.urlParamNames, DEFAULT_URL_PARAM_NAMES);
}
protected String getRequestUrl(SolrRequest<?> solrRequest, String collection)