Skip to content

Comments

Migrate org.apache.solr.cli tools from V1 to V2 APIs#4154

Open
epugh wants to merge 5 commits intoapache:mainfrom
epugh:migrate-cli-to-v2-apache
Open

Migrate org.apache.solr.cli tools from V1 to V2 APIs#4154
epugh wants to merge 5 commits intoapache:mainfrom
epugh:migrate-cli-to-v2-apache

Conversation

@epugh
Copy link
Contributor

@epugh epugh commented Feb 22, 2026

Replaces legacy V1 admin API calls (CollectionAdminRequest, CoreAdminRequest) in the bin/solr CLI tools with generated V2 OpenAPI SolrJ classes. Also adds a new proper SolrJ V2 endpoint for GET /cluster/nodes that was previously missing, eliminating the need for a GenericV2SolrRequest workaround.

I used Copilot for this, and here is the agent chat: https://github.com/epugh/solr/tasks/3c2f15c6-c0c7-4e39-b6b6-1cd51f8e7aa4

Migrated calls

Class Method Before → After
CLIUtils safeCheckCollectionExists CollectionAdminRequest.ListCollectionsApi.ListCollections
CreateTool createCore CoreAdminRequest.createCoreCoresApi.CreateCore
CreateTool createCollection CollectionAdminRequest.createCollectionCollectionsApi.CreateCollection
DeleteTool deleteCollection CollectionAdminRequest.deleteCollectionCollectionsApi.DeleteCollection
DeleteTool deleteCore CoreAdminRequest.UnloadCoresApi.UnloadCore
StatusTool getCloudStatus CollectionAdminRequest.ClusterStatusClusterApi.ListClusterNodes + CollectionsApi.ListCollections

Verbose output restored via Jackson

The old V1 code serialized NamedList responses with noggit's JSONWriter. V2 response POJOs are Jackson-annotated, so verbose output now uses JacksonContentWriter.DEFAULT_MAPPER.writerWithDefaultPrettyPrinter() — actually cleaner output since the responses are already proper JSON objects:

// CreateTool, DeleteTool — after req.process():
if (isVerbose() && response != null) {
  echo(JacksonContentWriter.DEFAULT_MAPPER
      .writerWithDefaultPrettyPrinter()
      .writeValueAsString(response));
}

New GET /cluster/nodes V2 API (SolrJ support)

StatusTool previously fell back to GenericV2SolrRequest because SolrJ had no typed class for this endpoint. The full API pipeline was wired up:

  • ListClusterNodesResponse — new model with Set<String> nodes
  • ListClusterNodesApi — new endpoint interface at @Path("/cluster/nodes")
  • ListClusterNodes — new Jersey implementation registered in CollectionsHandler
  • ClusterApi.ListClusterNodes — generated SolrJ request class (replaces GenericV2SolrRequest)
// Before
NamedList<Object> resp = solrClient.request(
    new GenericV2SolrRequest(SolrRequest.METHOD.GET, "/cluster/nodes", SolrRequestType.ADMIN));
var liveNodes = (Collection<?>) resp.get("nodes");

// After
var resp = new ClusterApi.ListClusterNodes().process(solrClient);
var liveNodes = resp.nodes; // Set<String>

Not migrated

Snapshot tools (SnapshotCreateTool, SnapshotDeleteTool, etc.) are intentionally excluded as candidates for removal.

In fact, we may just remove them...?

Tests

Existing tests + bats tests all pass.

Copilot AI and others added 5 commits February 21, 2026 19:10
Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
…r/nodes + /collections APIs

Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
… POJOs

Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants