This is an automated email from the ASF dual-hosted git repository.

epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 1c673ce5b4f SOLR-16398: Migrate SplitCore from @EndPoint/@Command to 
JAX-RS (#4179)
1c673ce5b4f is described below

commit 1c673ce5b4fa1a43342ccdacab1d02f150c7c1eb
Author: Eric Pugh <[email protected]>
AuthorDate: Tue Nov 10 15:00:48 2026 -0500

    SOLR-16398: Migrate SplitCore from @EndPoint/@Command to JAX-RS (#4179)
    
    Co-authored-by: copilot-swe-agent[bot] 
<[email protected]>
    Co-authored-by: epugh <[email protected]>
    Co-authored-by: Claude Sonnet 5 <[email protected]>
---
 .../unreleased/migrate-splitcoreapi-to-jaxrs.yml   |   7 +
 .../solr/client/api/endpoint/SplitCoreApi.java     |  47 ++
 .../client/api/model/SplitCoreRequestBody.java     |  55 ++
 .../solr/client/api/model/SplitCoreResponse.java   |  36 ++
 .../solr/handler/admin/CoreAdminHandler.java       |   2 +-
 .../org/apache/solr/handler/admin/SplitOp.java     | 615 ++----------------
 .../solr/handler/admin/api/CoreAdminAPIBase.java   |   4 +-
 .../solr/handler/admin/api/SplitCoreAPI.java       | 684 +++++++++++++++++++--
 .../solr/handler/admin/api/SplitCoreAPITest.java   | 216 +++++++
 .../handler/admin/{ => api}/SplitHandlerTest.java  |  82 +--
 .../handler/admin/api/V2CoreAPIMappingTest.java    |  36 --
 .../configuration-guide/pages/coreadmin-api.adoc   |  99 ++-
 12 files changed, 1178 insertions(+), 705 deletions(-)

diff --git a/changelog/unreleased/migrate-splitcoreapi-to-jaxrs.yml 
b/changelog/unreleased/migrate-splitcoreapi-to-jaxrs.yml
new file mode 100644
index 00000000000..77d1099073b
--- /dev/null
+++ b/changelog/unreleased/migrate-splitcoreapi-to-jaxrs.yml
@@ -0,0 +1,7 @@
+title: The v2 core split API (`/cores/{core}/split`) now has generated SolrJ 
client support (`CoresApi.SplitCore`).
+type: changed
+authors:
+  - name: Eric Pugh
+links:
+- name: PR#4179
+  url: https://github.com/apache/solr/pull/4179
diff --git 
a/solr/api/src/java/org/apache/solr/client/api/endpoint/SplitCoreApi.java 
b/solr/api/src/java/org/apache/solr/client/api/endpoint/SplitCoreApi.java
new file mode 100644
index 00000000000..304d40e500c
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/endpoint/SplitCoreApi.java
@@ -0,0 +1,47 @@
+/*
+ * 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.api.endpoint;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import org.apache.solr.client.api.model.SplitCoreRequestBody;
+import org.apache.solr.client.api.model.SplitCoreResponse;
+
+/**
+ * V2 API definition for splitting a Solr core.
+ *
+ * <p>The new API (POST /api/cores/{coreName}/split) is equivalent to the v1
+ * /admin/cores?action=split command.
+ */
+@Path("/cores/{coreName}/split")
+public interface SplitCoreApi {
+  @POST
+  @Operation(
+      summary = "Splits a core index into two or more indexes.",
+      tags = {"cores"})
+  SplitCoreResponse splitCore(
+      @Parameter(description = "The name of the core to split.", required = 
true)
+          @PathParam("coreName")
+          String coreName,
+      @RequestBody(description = "Additional properties for the split 
operation.")
+          SplitCoreRequestBody requestBody)
+      throws Exception;
+}
diff --git 
a/solr/api/src/java/org/apache/solr/client/api/model/SplitCoreRequestBody.java 
b/solr/api/src/java/org/apache/solr/client/api/model/SplitCoreRequestBody.java
new file mode 100644
index 00000000000..ed32cfb7795
--- /dev/null
+++ 
b/solr/api/src/java/org/apache/solr/client/api/model/SplitCoreRequestBody.java
@@ -0,0 +1,55 @@
+/*
+ * 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.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import java.util.List;
+
+/**
+ * Request body for splitting a Solr core via {@link
+ * org.apache.solr.client.api.endpoint.SplitCoreApi}
+ */
+public class SplitCoreRequestBody {
+  @Schema(description = "Multi-valued, file system paths to write the split 
pieces to.")
+  @JsonProperty
+  public List<String> path;
+
+  @Schema(description = "Multi-valued, names of the cores to split the index 
into.")
+  @JsonProperty
+  public List<String> targetCore;
+
+  @Schema(description = "A route key to be used for splitting the index.")
+  @JsonProperty
+  public String splitKey;
+
+  @Schema(description = "The method to use for splitting the index (e.g. 
'rewrite' or 'link').")
+  @JsonProperty
+  public String splitMethod;
+
+  @Schema(description = "When true, returns the range recommendations for 
splitting the index.")
+  @JsonProperty
+  public Boolean getRanges;
+
+  @Schema(description = "Comma-separated hash ranges to split the index into 
(e.g. 'a-b,c-d').")
+  @JsonProperty
+  public String ranges;
+
+  @Schema(description = "Request ID to track this action which will be 
processed asynchronously.")
+  @JsonProperty
+  public String async;
+}
diff --git 
a/solr/api/src/java/org/apache/solr/client/api/model/SplitCoreResponse.java 
b/solr/api/src/java/org/apache/solr/client/api/model/SplitCoreResponse.java
new file mode 100644
index 00000000000..3bac732984c
--- /dev/null
+++ b/solr/api/src/java/org/apache/solr/client/api/model/SplitCoreResponse.java
@@ -0,0 +1,36 @@
+/*
+ * 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.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import java.util.Map;
+
+/** Response body for {@link 
org.apache.solr.client.api.endpoint.SplitCoreApi#splitCore} */
+public class SplitCoreResponse extends AsyncJerseyResponse {
+
+  @Schema(
+      description =
+          "Comma-separated hash ranges recommended for splitting the index, 
present only when "
+              + "the request's 'getRanges' property is true.")
+  @JsonProperty
+  public String ranges;
+
+  @Schema(description = "Per-phase timing information for a completed index 
split.")
+  @JsonProperty
+  public Map<String, Object> timing;
+}
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java 
b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
index e1d02565b9b..0e33b84408e 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
@@ -314,7 +314,6 @@ public class CoreAdminHandler extends RequestHandlerBase 
implements PermissionNa
     final List<Api> apis = new ArrayList<>();
     apis.addAll(AnnotatedApi.getApis(new RejoinLeaderElectionAPI(this)));
     apis.addAll(AnnotatedApi.getApis(new OverseerOperationAPI(this)));
-    apis.addAll(AnnotatedApi.getApis(new SplitCoreAPI(this)));
     // Internal APIs
     apis.addAll(AnnotatedApi.getApis(new RequestCoreRecoveryAPI(this)));
     apis.addAll(AnnotatedApi.getApis(new PrepareCoreRecoveryAPI(this)));
@@ -339,6 +338,7 @@ public class CoreAdminHandler extends RequestHandlerBase 
implements PermissionNa
         SwapCores.class,
         RenameCore.class,
         MergeIndexes.class,
+        SplitCoreAPI.class,
         GetNodeCommandStatus.class);
   }
 
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SplitOp.java 
b/solr/core/src/java/org/apache/solr/handler/admin/SplitOp.java
index 4631c7f62be..d48aeae1633 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SplitOp.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SplitOp.java
@@ -17,59 +17,28 @@
 
 package org.apache.solr.handler.admin;
 
-import static org.apache.solr.common.params.CommonParams.PATH;
-import static org.apache.solr.common.params.CoreAdminParams.GET_RANGES;
-
-import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.TreeMap;
-import org.apache.lucene.index.MultiTerms;
-import org.apache.lucene.index.Terms;
-import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.StringHelper;
-import org.apache.solr.cloud.CloudDescriptor;
-import org.apache.solr.cloud.ZkShardTerms;
-import org.apache.solr.cloud.api.collections.SplitShardCmd;
+import java.util.Optional;
+import org.apache.solr.client.api.model.SplitCoreRequestBody;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.common.cloud.ClusterState;
-import org.apache.solr.common.cloud.CompositeIdRouter;
-import org.apache.solr.common.cloud.DocCollection;
-import org.apache.solr.common.cloud.DocCollection.CollectionStateProps;
-import org.apache.solr.common.cloud.DocRouter;
-import org.apache.solr.common.cloud.Slice;
 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.SolrParams;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.request.SolrQueryRequestBase;
-import org.apache.solr.search.SolrIndexSearcher;
-import org.apache.solr.update.SolrIndexSplitter;
-import org.apache.solr.update.SplitIndexCommand;
-import org.apache.solr.update.UpdateHandler;
-import org.apache.solr.util.RTimer;
-import org.apache.solr.util.RefCounted;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.solr.handler.admin.api.SplitCoreAPI;
+import org.apache.solr.handler.admin.api.SplitCoreAPI.CoreNotFoundException;
 
 /**
- * CoreAdminOp implementation for shard splits. This request is enqueued when 
{@link SplitShardCmd}
- * is processed. This operation handles two types of requests: 1. If {@link
- * CommonAdminParams#SPLIT_BY_PREFIX} is true, the request to calculate 
document ranges for the
- * sub-shards is processed here. 2. For any split request, the actual index 
split is processed here.
- * This calls into {@link UpdateHandler#split(SplitIndexCommand)} to execute 
split.
+ * CoreAdminOp implementation for shard splits. This request is enqueued when 
{@link
+ * org.apache.solr.cloud.api.collections.SplitShardCmd} is processed. This 
operation handles two
+ * types of requests: 1. If {@link CommonAdminParams#SPLIT_BY_PREFIX} is true, 
the request to
+ * calculate document ranges for the sub-shards is processed here. 2. For any 
split request, the
+ * actual index split is processed here.
+ *
+ * <p>The actual split logic lives in {@link SplitCoreAPI}.
  */
 class SplitOp implements CoreAdminHandler.CoreAdminOp {
 
-  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
   @Override
   public boolean isExpensive() {
     return true;
@@ -78,540 +47,36 @@ class SplitOp implements CoreAdminHandler.CoreAdminOp {
   @Override
   public void execute(CoreAdminHandler.CallInfo it) throws Exception {
     SolrParams params = it.req.getParams();
-    String splitKey = params.get("split.key");
-    String[] newCoreNames = params.getParams("targetCore");
-    String cname = params.get(CoreAdminParams.CORE, "");
-
-    // if split request has splitByPrefix set to true, we will first make a 
request to SplitOp
-    // to calculate the prefix ranges, and do the actual split in a separate 
request
-    if (params.getBool(GET_RANGES, false)) {
-      handleGetRanges(it, cname);
-      return;
-    }
-
-    // if not using splitByPrefix, determine split partitions
-    List<DocRouter.Range> ranges = null;
-
-    String[] pathsArr = params.getParams(PATH);
-    String rangesStr = params.get(CoreAdminParams.RANGES); // 
ranges=a-b,c-d,e-f
-    if (rangesStr != null) {
-      String[] rangesArr = rangesStr.split(",");
-      if (rangesArr.length == 0) {
-        throw new SolrException(
-            SolrException.ErrorCode.BAD_REQUEST,
-            "There must be at least one range specified to split an index");
-      } else {
-        ranges = new ArrayList<>(rangesArr.length);
-        for (String r : rangesArr) {
-          try {
-            ranges.add(DocRouter.DEFAULT.fromString(r));
-          } catch (Exception e) {
-            throw new SolrException(
-                SolrException.ErrorCode.BAD_REQUEST,
-                "Exception parsing hexadecimal hash range: " + r,
-                e);
-          }
-        }
-      }
-    }
-
-    // if not using splitByPrefix, ensure either path or targetCore specified
-    if ((pathsArr == null || pathsArr.length == 0)
-        && (newCoreNames == null || newCoreNames.length == 0)) {
-      throw new SolrException(
-          SolrException.ErrorCode.BAD_REQUEST, "Either path or targetCore 
param must be specified");
-    }
-
-    log.info("Invoked split action for core: {}", cname);
-    String methodStr =
-        params.get(CommonAdminParams.SPLIT_METHOD, 
SolrIndexSplitter.SplitMethod.REWRITE.toLower());
-    SolrIndexSplitter.SplitMethod splitMethod = 
SolrIndexSplitter.SplitMethod.get(methodStr);
-    if (splitMethod == null) {
-      throw new SolrException(
-          SolrException.ErrorCode.BAD_REQUEST,
-          "Unsupported value of '" + CommonAdminParams.SPLIT_METHOD + "': " + 
methodStr);
-    }
-    SolrCore parentCore = it.handler.coreContainer.getCore(cname);
-    List<SolrCore> newCores = null;
-    SolrQueryRequest req = null;
-
-    try {
-      // TODO: allow use of rangesStr in the future
-      List<String> paths = null;
-      int partitions = pathsArr != null ? pathsArr.length : 
newCoreNames.length;
-
-      DocRouter router = null;
-      String routeFieldName = null;
-      // if in SolrCloud mode, get collection and shard names
-      if (it.handler.coreContainer.isZooKeeperAware()) {
-        log.trace("SplitOp: Determine which router is associated with the 
shard for core");
-        ClusterState clusterState = 
it.handler.coreContainer.getZkController().getClusterState();
-        String collectionName =
-            
parentCore.getCoreDescriptor().getCloudDescriptor().getCollectionName();
-        DocCollection collection = clusterState.getCollection(collectionName);
-        String sliceName = 
parentCore.getCoreDescriptor().getCloudDescriptor().getShardId();
-        Slice slice = collection.getSlice(sliceName);
-        router = collection.getRouter() != null ? collection.getRouter() : 
DocRouter.DEFAULT;
-        if (ranges == null) {
-          DocRouter.Range currentRange = slice.getRange();
-          ranges = currentRange != null ? router.partitionRange(partitions, 
currentRange) : null;
-        }
-        Object routerObj =
-            collection.get(CollectionStateProps.DOC_ROUTER); // for 
back-compat with Solr 4.4
-        if (routerObj instanceof Map<?, ?> routerProps) {
-          routeFieldName = (String) routerProps.get("field");
-        }
-      }
-
-      if (pathsArr == null) {
-        log.trace("SplitOp: Create array of paths for sub-shards of core");
-        newCores = new ArrayList<>(partitions);
-        for (String newCoreName : newCoreNames) {
-          SolrCore newcore = it.handler.coreContainer.getCore(newCoreName);
-          if (newcore != null) {
-            newCores.add(newcore);
-            if (it.handler.coreContainer.isZooKeeperAware()) {
-              // this core must be the only replica in its shard otherwise
-              // we cannot guarantee consistency between replicas because when 
we add data to this
-              // replica
-              CloudDescriptor cd = 
newcore.getCoreDescriptor().getCloudDescriptor();
-              ClusterState clusterState =
-                  it.handler.coreContainer.getZkController().getClusterState();
-              if (clusterState
-                      .getCollection(cd.getCollectionName())
-                      .getSlice(cd.getShardId())
-                      .getReplicas()
-                      .size()
-                  != 1) {
-                throw new SolrException(
-                    SolrException.ErrorCode.BAD_REQUEST,
-                    "Core with core name "
-                        + newCoreName
-                        + " must be the only replica in shard "
-                        + cd.getShardId());
-              }
-            }
-          } else {
-            throw new SolrException(
-                SolrException.ErrorCode.BAD_REQUEST,
-                "Core with core name " + newCoreName + " expected but doesn't 
exist.");
-          }
-        }
-      } else {
-        paths = Arrays.asList(pathsArr);
-      }
-
-      req = new SolrQueryRequestBase(parentCore, params);
-
-      SplitIndexCommand cmd =
-          new SplitIndexCommand(
-              req, it.rsp, paths, newCores, ranges, router, routeFieldName, 
splitKey, splitMethod);
-      parentCore.getUpdateHandler().split(cmd);
-
-      if (it.handler.coreContainer.isZooKeeperAware()) {
-        log.trace("SplitOp: Create cloud descriptors for sub-shards of core");
-        for (SolrCore newcore : newCores) {
-          // the index of the core changed from empty to have some data, its 
term must be not zero
-          CloudDescriptor cd = 
newcore.getCoreDescriptor().getCloudDescriptor();
-          ZkShardTerms zkShardTerms =
-              it.handler
-                  .coreContainer
-                  .getZkController()
-                  .getShardTerms(cd.getCollectionName(), cd.getShardId());
-          zkShardTerms.ensureHighestTermsAreNotZero();
-        }
-      }
-
-      // After the split has completed, someone (here?) should start the 
process of replaying the
-      // buffered updates.
-    } catch (Exception e) {
-      log.error("ERROR executing split: ", e);
-      throw e;
-    } finally {
-      if (req != null) req.close();
-      if (parentCore != null) parentCore.close();
-      if (newCores != null) {
-        for (SolrCore newCore : newCores) {
-          newCore.close();
-        }
-      }
-    }
-  }
-
-  /**
-   * This is called when splitByPrefix is used. The overseer called us to get 
recommended splits
-   * taking into account actual document distribution over the hash space.
-   */
-  private void handleGetRanges(CoreAdminHandler.CallInfo it, String coreName) 
throws Exception {
-
-    SolrCore parentCore = it.handler.coreContainer.getCore(coreName);
-    if (parentCore == null) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown 
core " + coreName);
-    }
-
-    RefCounted<SolrIndexSearcher> searcherHolder = 
parentCore.getRealtimeSearcher();
-
+    String cname = params.get(CoreAdminParams.CORE);
+
+    final var requestBody = new SplitCoreRequestBody();
+    Optional.ofNullable(params.getParams(CommonParams.PATH))
+        .ifPresent(val -> requestBody.path = Arrays.asList(val));
+    Optional.ofNullable(params.getParams(CoreAdminParams.TARGET_CORE))
+        .ifPresent(val -> requestBody.targetCore = Arrays.asList(val));
+    requestBody.splitKey = params.get(CommonAdminParams.SPLIT_KEY);
+    requestBody.splitMethod = params.get(CommonAdminParams.SPLIT_METHOD);
+    requestBody.getRanges = params.getBool(CoreAdminParams.GET_RANGES);
+    requestBody.ranges = params.get(CoreAdminParams.RANGES);
+    // 'async' is deliberately not copied here: 
CoreAdminHandler.handleRequestBody() already
+    // wraps this whole execute() call in an async task using the v1 request's 
'async' param, so
+    // passing it through as well would make SplitCoreAPI try to register the 
same task id twice.
+
+    final var splitCoreApi =
+        new SplitCoreAPI(
+            it.handler.coreContainer, it.handler.coreAdminAsyncTracker, 
it.req, it.rsp);
     try {
-      if (!it.handler.coreContainer.isZooKeeperAware()) {
-        throw new SolrException(
-            SolrException.ErrorCode.BAD_REQUEST, "Shard splitByPrefix requires 
SolrCloud mode.");
-      } else {
-        SolrIndexSearcher searcher = searcherHolder.get();
-
-        String routeFieldName = null;
-        String prefixField = "id_prefix";
-
-        ClusterState clusterState = 
it.handler.coreContainer.getZkController().getClusterState();
-        String collectionName =
-            
parentCore.getCoreDescriptor().getCloudDescriptor().getCollectionName();
-        DocCollection collection = clusterState.getCollection(collectionName);
-        String sliceName = 
parentCore.getCoreDescriptor().getCloudDescriptor().getShardId();
-        Slice slice = collection.getSlice(sliceName);
-        CompositeIdRouter router =
-            (CompositeIdRouter)
-                (collection.getRouter() != null ? collection.getRouter() : 
DocRouter.DEFAULT);
-        DocRouter.Range currentRange = slice.getRange();
-
-        Object routerObj =
-            collection.get(CollectionStateProps.DOC_ROUTER); // for 
back-compat with Solr 4.4
-        if (routerObj instanceof Map<?, ?> routerProps) {
-          routeFieldName = (String) routerProps.get("field");
-        }
-        if (routeFieldName == null) {
-          routeFieldName = searcher.getSchema().getUniqueKeyField().getName();
-        }
-
-        Collection<RangeCount> counts = getHashHistogram(searcher, 
prefixField, router, collection);
-
-        if (counts.size() == 0) {
-          // How to determine if we should look at the id field to figure out 
the prefix buckets?
-          // There may legitimately be no indexed terms in id_prefix if no ids 
have a prefix yet.
-          // For now, avoid using splitByPrefix unless you are actually using 
prefixes.
-          counts =
-              getHashHistogramFromId(
-                  searcher, 
searcher.getSchema().getUniqueKeyField().getName(), router, collection);
-        }
-
-        Collection<DocRouter.Range> splits = getSplits(counts, currentRange);
-        String splitString = toSplitString(splits);
-
-        if (splitString == null) {
-          return;
-        }
-
-        it.rsp.add(CoreAdminParams.RANGES, splitString);
-      }
-    } finally {
-      if (searcherHolder != null) searcherHolder.decref();
-      if (parentCore != null) parentCore.close();
-    }
-  }
-
-  static class RangeCount implements Comparable<RangeCount> {
-    DocRouter.Range range;
-    int count;
-
-    public RangeCount(DocRouter.Range range, int count) {
-      this.range = range;
-      this.count = count;
-    }
-
-    @Override
-    public int hashCode() {
-      return range.hashCode();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-      if (!(obj instanceof RangeCount)) return false;
-      return this.range.equals(((RangeCount) obj).range);
-    }
-
-    @Override
-    public int compareTo(RangeCount o) {
-      return this.range.compareTo(o.range);
-    }
-
-    @Override
-    public String toString() {
-      return range.toString() + "=" + count;
-    }
-  }
-
-  static String toSplitString(Collection<DocRouter.Range> splits) throws 
Exception {
-    if (splits == null) {
-      return null;
-    }
-
-    StringBuilder sb = new StringBuilder();
-    for (DocRouter.Range range : splits) {
-      if (sb.length() > 0) {
-        sb.append(",");
-      }
-      sb.append(range);
-    }
-
-    return sb.toString();
-  }
-
-  /*
-   * Returns a list of range counts sorted by the range lower bound
-   */
-  static Collection<RangeCount> getHashHistogram(
-      SolrIndexSearcher searcher,
-      String prefixField,
-      CompositeIdRouter router,
-      DocCollection collection)
-      throws IOException {
-    RTimer timer = new RTimer();
-    TreeMap<DocRouter.Range, RangeCount> counts = new TreeMap<>();
-
-    Terms terms = MultiTerms.getTerms(searcher.getIndexReader(), prefixField);
-    if (terms == null) {
-      return counts.values();
-    }
-
-    int numPrefixes = 0;
-    int numTriLevel = 0;
-    int numCollisions = 0;
-    long sumBuckets = 0;
-
-    TermsEnum termsEnum = terms.iterator();
-    BytesRef term;
-    while ((term = termsEnum.next()) != null) {
-      numPrefixes++;
-
-      // truncate to first separator since we don't support multiple levels 
currently
-      // NOTE: this does not currently work for tri-level composite ids since 
the number of bits
-      // allocated to the first ID is 16 for a 2 part id and 8 for a 3 part id!
-      String termStr;
-      int routeKeyLen = router.getRouteKeyWithSeparator(term.bytes, 
term.offset, term.length);
-      if (routeKeyLen == 0 || routeKeyLen == term.length) {
-        termStr = term.utf8ToString();
-      } else {
-        int prevLen = term.length;
-        term.length = routeKeyLen;
-        termStr = term.utf8ToString();
-        term.length = prevLen; // restore    (Question: must we do this?)
-      }
-
-      DocRouter.Range range = router.getSearchRangeSingle(termStr, null, 
collection);
-      int numDocs = termsEnum.docFreq();
-      sumBuckets += numDocs;
-
-      RangeCount rangeCount = new RangeCount(range, numDocs);
-
-      RangeCount prev = counts.put(rangeCount.range, rangeCount);
-      if (prev != null) {
-        // we hit a hash collision or truncated a prefix to first level, so 
add the buckets
-        // together.
-        rangeCount.count += prev.count;
-        numCollisions++;
-      }
-    }
-
-    if (log.isInfoEnabled()) {
-      log.info(
-          "Split histogram: ms={}, numBuckets={} sumBuckets={} numPrefixes={} 
numTriLevel={} numCollisions={}",
-          timer.getTime(),
-          counts.size(),
-          sumBuckets,
-          numPrefixes,
-          numTriLevel,
-          numCollisions);
-    }
-
-    return counts.values();
-  }
-
-  /**
-   * Returns a list of range counts sorted by the range lower bound, using the 
indexed "id" field
-   * (i.e. the terms are full IDs, not just prefixes)
-   */
-  static Collection<RangeCount> getHashHistogramFromId(
-      SolrIndexSearcher searcher,
-      String idField,
-      CompositeIdRouter router,
-      DocCollection collection)
-      throws IOException {
-    RTimer timer = new RTimer();
-
-    TreeMap<DocRouter.Range, RangeCount> counts = new TreeMap<>();
-
-    Terms terms = MultiTerms.getTerms(searcher.getIndexReader(), idField);
-    if (terms == null) {
-      return counts.values();
-    }
-
-    int numPrefixes = 0;
-    int numCollisions = 0;
-    long sumBuckets = 0;
-
-    TermsEnum termsEnum = terms.iterator();
-    BytesRef currPrefix = new BytesRef(); // prefix of the previous "id" term 
WITH SEPARATOR
-    int bucketCount = 0; // count of the number of docs in the current bucket
-
-    // We're going to iterate over all terms, so do the minimum amount of work 
per term.
-    // Terms are sorted, so all terms sharing a prefix will be grouped 
together.  The extra work
-    // is really just limited to stepping over all the terms in the id field.
-    for (; ; ) {
-      BytesRef term = termsEnum.next();
-
-      // compare to current prefix bucket and see if this new term shares the 
same prefix
-      if (term != null && currPrefix.length > 0) {
-        // since currPrefix includes the trailing separator, we can assume 
startsWith is a
-        // sufficient test
-        if (StringHelper.startsWith(term, currPrefix)) {
-          bucketCount++; // use 1 since we are dealing with unique ids
-          continue;
-        }
-      }
-
-      // At this point the prefix did not match, so if we had a bucket we were 
working on, record
-      // it.
-      if (currPrefix.length > 0) {
-        numPrefixes++;
-        sumBuckets += bucketCount;
-        String currPrefixStr = currPrefix.utf8ToString();
-        DocRouter.Range range = router.getSearchRangeSingle(currPrefixStr, 
null, collection);
-
-        RangeCount rangeCount = new RangeCount(range, bucketCount);
-        bucketCount = 0;
-
-        RangeCount prev = counts.put(rangeCount.range, rangeCount);
-        if (prev != null) {
-          // we hit a hash collision, so add the buckets together.
-          rangeCount.count += prev.count;
-          numCollisions++;
-        }
-      }
-
-      // if the current term is null, we ran out of values
-      if (term == null) break;
-
-      // find the new prefix (if any), with trailing separator
-      currPrefix.length = router.getRouteKeyWithSeparator(term.bytes, 
term.offset, term.length);
-      if (currPrefix.length > 0) {
-        // resize if needed
-        if (currPrefix.length > currPrefix.bytes.length) {
-          currPrefix.bytes = new byte[currPrefix.length + 10];
-        }
-        System.arraycopy(term.bytes, term.offset, currPrefix.bytes, 0, 
currPrefix.length);
-
-        bucketCount++;
-      }
-    }
-
-    if (log.isInfoEnabled()) {
-      log.info(
-          "Split histogram from idField {}: ms={}, numBuckets={} sumBuckets={} 
numPrefixes={} numCollisions={}",
-          idField,
-          timer.getTime(),
-          counts.size(),
-          sumBuckets,
-          numPrefixes,
-          numCollisions);
-    }
-
-    return counts.values();
-  }
-
-  /*
-   * Returns the list of recommended splits, or null if there is not enough 
information
-   */
-  static Collection<DocRouter.Range> getSplits(
-      Collection<RangeCount> rawCounts, DocRouter.Range currentRange) throws 
Exception {
-    int totalCount = 0;
-    // keep track of the largest in case we need to split it out into it's own 
shard
-    RangeCount biggest = null;
-    RangeCount last = null; // keep track of what the last range is
-
-    // Remove counts that don't overlap with currentRange (can happen if 
someone overrode document
-    // routing)
-    List<RangeCount> counts = new ArrayList<>(rawCounts.size());
-    for (RangeCount rangeCount : rawCounts) {
-      if (!rangeCount.range.overlaps(currentRange)) {
-        continue;
-      }
-      totalCount += rangeCount.count;
-      if (biggest == null || rangeCount.count > biggest.count) {
-        biggest = rangeCount;
+      final var response = splitCoreApi.splitCore(cname, requestBody);
+      if (response.ranges != null) {
+        it.rsp.add("ranges", response.ranges);
       }
-      counts.add(rangeCount);
-      last = rangeCount;
-    }
-
-    if (counts.size() == 0) {
-      // we don't have any data to go off of, so do the split the normal way
-      return null;
-    }
-
-    List<DocRouter.Range> targetRanges = new ArrayList<>();
-
-    if (counts.size() == 1) {
-      // We have a single range, so we should split it.
-      // Currently, we only split a prefix/bucket when we have just one, but 
this could be
-      // changed/controlled in the future via a allowedSizeDifference 
parameter (i.e. if just
-      // separating prefix buckets results in too large of an imbalanced, 
allow splitting within a
-      // prefix)
-
-      // It may already be a partial range, so figure that out
-      int lower = Math.max(last.range.min, currentRange.min);
-      int upper = Math.min(last.range.max, currentRange.max);
-      int mid = lower + (upper - lower) / 2;
-      if (mid == lower || mid == upper) {
-        // shard too small... this should pretty much never happen, but use 
default split logic if
-        // it does.
-        return null;
-      }
-
-      // Make sure to include the shard's current range in the new ranges so 
we don't create useless
-      // empty shards.
-      DocRouter.Range lowerRange = new DocRouter.Range(currentRange.min, mid);
-      DocRouter.Range upperRange = new DocRouter.Range(mid + 1, 
currentRange.max);
-      targetRanges.add(lowerRange);
-      targetRanges.add(upperRange);
-
-      return targetRanges;
-    }
-
-    // We have at least two ranges, so we want to partition the ranges
-    // and avoid splitting any individual range.
-    // The "middle" bucket we are going to find will be included with the 
lower range and excluded
-    // from the upper range.
-
-    int targetCount = totalCount / 2;
-    RangeCount middle = null;
-    RangeCount prev = null;
-    int currCount = 0;
-    for (RangeCount rangeCount : counts) {
-      currCount += rangeCount.count;
-      if (currCount >= targetCount) { // this should at least be true on the 
last range
-        middle = rangeCount;
-        break;
-      }
-      prev = rangeCount;
-    }
-
-    // check if using the range before the middle one would make a better 
split point
-    int overError = currCount - targetCount; // error if we include middle in 
first split
-    int underError =
-        targetCount - (currCount - middle.count); // error if we include 
middle in second split
-    if (underError < overError) {
-      middle = prev;
+    } catch (CoreNotFoundException e) {
+      throw new SolrException(
+          Boolean.TRUE.equals(requestBody.getRanges)
+              ? SolrException.ErrorCode.BAD_REQUEST
+              : SolrException.ErrorCode.SERVER_ERROR,
+          e.getMessage(),
+          e);
     }
-
-    // The middle should never be the last, since that means that we won't 
actually do a split.
-    // Minimising the error (above) should already ensure this never happens.
-    assert !Objects.equals(middle, last);
-
-    // Make sure to include the shard's current range in the new ranges so we 
don't create useless
-    // empty shards.
-    DocRouter.Range lowerRange = new DocRouter.Range(currentRange.min, 
middle.range.max);
-    DocRouter.Range upperRange = new DocRouter.Range(middle.range.max + 1, 
currentRange.max);
-    targetRanges.add(lowerRange);
-    targetRanges.add(upperRange);
-
-    return targetRanges;
   }
 }
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/CoreAdminAPIBase.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/CoreAdminAPIBase.java
index 79f0a4d71f5..b7354d2ddfd 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/CoreAdminAPIBase.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/CoreAdminAPIBase.java
@@ -109,7 +109,9 @@ public abstract class CoreAdminAPIBase extends 
JerseyResource {
     } catch (CoreAdminAPIBaseException e) {
       throw e.trueException;
     } finally {
-      rsp.setHttpCaching(false);
+      if (rsp != null) {
+        rsp.setHttpCaching(false);
+      }
     }
 
     return solrJerseyResponse;
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/SplitCoreAPI.java 
b/solr/core/src/java/org/apache/solr/handler/admin/api/SplitCoreAPI.java
index e12fc60f182..57b73c9ba9b 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/SplitCoreAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/SplitCoreAPI.java
@@ -14,85 +14,669 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.solr.handler.admin.api;
 
-import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
-import static org.apache.solr.common.params.CommonAdminParams.SPLIT_KEY;
-import static org.apache.solr.common.params.CommonParams.PATH;
-import static org.apache.solr.common.params.CoreAdminParams.TARGET_CORE;
-import static org.apache.solr.handler.ClusterAPI.wrapParams;
 import static 
org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
 
-import java.util.HashMap;
+import jakarta.inject.Inject;
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
-import org.apache.solr.api.Command;
-import org.apache.solr.api.EndPoint;
-import org.apache.solr.api.PayloadObj;
-import org.apache.solr.common.annotation.JsonProperty;
-import org.apache.solr.common.params.CoreAdminParams;
-import org.apache.solr.common.util.ReflectMapWriter;
-import org.apache.solr.common.util.Utils;
+import java.util.Objects;
+import java.util.TreeMap;
+import org.apache.lucene.index.MultiTerms;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.StringHelper;
+import org.apache.solr.client.api.endpoint.SplitCoreApi;
+import org.apache.solr.client.api.model.SplitCoreRequestBody;
+import org.apache.solr.client.api.model.SplitCoreResponse;
+import org.apache.solr.cloud.CloudDescriptor;
+import org.apache.solr.cloud.ZkShardTerms;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.ClusterState;
+import org.apache.solr.common.cloud.CompositeIdRouter;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.DocCollection.CollectionStateProps;
+import org.apache.solr.common.cloud.DocRouter;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.admin.CoreAdminHandler;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequestBase;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.update.SolrIndexSplitter;
+import org.apache.solr.update.SplitIndexCommand;
+import org.apache.solr.util.RTimer;
+import org.apache.solr.util.RefCounted;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * V2 API for splitting a single core into multiple pieces
+ * V2 API for splitting a single core into multiple pieces.
  *
- * <p>The new API (POST /v2/cores/coreName {'split': {...}}) is equivalent to 
the v1
+ * <p>The new API (POST /v2/cores/{coreName}/split) is equivalent to the v1
  * /admin/cores?action=split command.
  */
-@EndPoint(
-    path = {"/cores/{core}"},
-    method = POST,
-    permission = CORE_EDIT_PERM)
-public class SplitCoreAPI {
-  private static final String V2_SPLIT_CORE_CMD = "split";
+public class SplitCoreAPI extends CoreAdminAPIBase implements SplitCoreApi {
+
+  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  @Inject
+  public SplitCoreAPI(
+      CoreContainer coreContainer,
+      CoreAdminHandler.CoreAdminAsyncTracker coreAdminAsyncTracker,
+      SolrQueryRequest req,
+      SolrQueryResponse rsp) {
+    super(coreContainer, coreAdminAsyncTracker, req, rsp);
+  }
+
+  @Override
+  public boolean isExpensive() {
+    return true;
+  }
+
+  @Override
+  @PermissionName(CORE_EDIT_PERM)
+  public SplitCoreResponse splitCore(String coreName, SplitCoreRequestBody 
requestBody)
+      throws Exception {
+    ensureRequiredParameterProvided("coreName", coreName);
+    final SplitCoreRequestBody body =
+        requestBody != null ? requestBody : new SplitCoreRequestBody();
+    final SplitCoreResponse response = 
instantiateJerseyResponse(SplitCoreResponse.class);
+
+    // splitByPrefix uses this internally to calculate document ranges for the 
sub-shards, via a
+    // synchronous sub-request that piggybacks an internal correlation id on 
the 'async' param.
+    // That id must not be treated as a real async task id, so this bypasses
+    // handlePotentiallyAsynchronousTask entirely, matching the original 
SplitOp behavior.
+    if (Boolean.TRUE.equals(body.getRanges)) {
+      handleGetRanges(coreName, response);
+      return response;
+    }
+
+    response.requestId = body.async;
+    return handlePotentiallyAsynchronousTask(
+        response,
+        coreName,
+        body.async,
+        "split",
+        () -> {
+          try {
+            doSplit(coreName, body, response);
+            return response;
+          } catch (SolrException e) {
+            throw e;
+          } catch (Exception e) {
+            throw new CoreAdminAPIBaseException(e);
+          }
+        });
+  }
+
+  /**
+   * Splits the core's index, either into the directory paths in {@code 
body.path} or by merging
+   * pieces into the cores named in {@code body.targetCore}.
+   */
+  private void doSplit(String coreName, SplitCoreRequestBody body, 
SplitCoreResponse response)
+      throws Exception {
+    String splitKey = body.splitKey;
+    String[] newCoreNames = body.targetCore != null ? 
body.targetCore.toArray(new String[0]) : null;
+
+    List<DocRouter.Range> ranges = null;
+
+    String[] pathsArr = body.path != null ? body.path.toArray(new String[0]) : 
null;
+    String rangesStr = body.ranges; // ranges=a-b,c-d,e-f
+    if (rangesStr != null) {
+      String[] rangesArr = rangesStr.split(",");
+      if (rangesArr.length == 0) {
+        throw new SolrException(
+            SolrException.ErrorCode.BAD_REQUEST,
+            "There must be at least one range specified to split an index");
+      } else {
+        ranges = new ArrayList<>(rangesArr.length);
+        for (String r : rangesArr) {
+          try {
+            ranges.add(DocRouter.DEFAULT.fromString(r));
+          } catch (Exception e) {
+            throw new SolrException(
+                SolrException.ErrorCode.BAD_REQUEST,
+                "Exception parsing hexadecimal hash range: " + r,
+                e);
+          }
+        }
+      }
+    }
+
+    // ensure either path or targetCore specified
+    if ((pathsArr == null || pathsArr.length == 0)
+        && (newCoreNames == null || newCoreNames.length == 0)) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Either path or targetCore 
param must be specified");
+    }
+
+    log.info("Invoked split action for core: {}", coreName);
+    String methodStr =
+        body.splitMethod != null
+            ? body.splitMethod
+            : SolrIndexSplitter.SplitMethod.REWRITE.toLower();
+    SolrIndexSplitter.SplitMethod splitMethod = 
SolrIndexSplitter.SplitMethod.get(methodStr);
+    if (splitMethod == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Unsupported value of 
'splitMethod': " + methodStr);
+    }
+    SolrCore parentCore = getCoreOrThrow(coreName);
+    List<SolrCore> newCores = null;
+    SolrQueryRequest splitReq = null;
+
+    try {
+      // TODO: allow use of rangesStr in the future
+      List<String> paths = null;
+      int partitions = pathsArr != null ? pathsArr.length : 
newCoreNames.length;
+
+      DocRouter router = null;
+      String routeFieldName = null;
+      // if in SolrCloud mode, get collection and shard names
+      if (coreContainer.isZooKeeperAware()) {
+        log.trace("SplitCoreAPI: Determine which router is associated with the 
shard for core");
+        ClusterState clusterState = 
coreContainer.getZkController().getClusterState();
+        String collectionName =
+            
parentCore.getCoreDescriptor().getCloudDescriptor().getCollectionName();
+        DocCollection collection = clusterState.getCollection(collectionName);
+        String sliceName = 
parentCore.getCoreDescriptor().getCloudDescriptor().getShardId();
+        Slice slice = collection.getSlice(sliceName);
+        router = collection.getRouter() != null ? collection.getRouter() : 
DocRouter.DEFAULT;
+        if (ranges == null) {
+          DocRouter.Range currentRange = slice.getRange();
+          ranges = currentRange != null ? router.partitionRange(partitions, 
currentRange) : null;
+        }
+        Object routerObj =
+            collection.get(CollectionStateProps.DOC_ROUTER); // for 
back-compat with Solr 4.4
+        if (routerObj instanceof Map<?, ?> routerProps) {
+          routeFieldName = (String) routerProps.get("field");
+        }
+      }
+
+      if (pathsArr == null) {
+        log.trace("SplitCoreAPI: Create array of paths for sub-shards of 
core");
+        newCores = new ArrayList<>(partitions);
+        for (String newCoreName : newCoreNames) {
+          SolrCore newcore = coreContainer.getCore(newCoreName);
+          if (newcore != null) {
+            newCores.add(newcore);
+            if (coreContainer.isZooKeeperAware()) {
+              // this core must be the only replica in its shard otherwise
+              // we cannot guarantee consistency between replicas because when 
we add data to this
+              // replica
+              CloudDescriptor cd = 
newcore.getCoreDescriptor().getCloudDescriptor();
+              ClusterState clusterState = 
coreContainer.getZkController().getClusterState();
+              if (clusterState
+                      .getCollection(cd.getCollectionName())
+                      .getSlice(cd.getShardId())
+                      .getReplicas()
+                      .size()
+                  != 1) {
+                throw new SolrException(
+                    SolrException.ErrorCode.BAD_REQUEST,
+                    "Core with core name "
+                        + newCoreName
+                        + " must be the only replica in shard "
+                        + cd.getShardId());
+              }
+            }
+          } else {
+            throw new SolrException(
+                SolrException.ErrorCode.BAD_REQUEST,
+                "Core with core name " + newCoreName + " expected but doesn't 
exist.");
+          }
+        }
+      } else {
+        paths = Arrays.asList(pathsArr);
+      }
+
+      splitReq = new SolrQueryRequestBase(parentCore, req.getParams());
+
+      SplitIndexCommand cmd =
+          new SplitIndexCommand(
+              splitReq,
+              rsp,
+              paths,
+              newCores,
+              ranges,
+              router,
+              routeFieldName,
+              splitKey,
+              splitMethod);
+      parentCore.getUpdateHandler().split(cmd);
+      if (rsp.getResponse() instanceof NamedList<?> results
+          && results.get(CommonParams.TIMING) instanceof NamedList<?> timing) {
+        final Map<String, Object> timingByPhase = new LinkedHashMap<>();
+        timing.forEach(timingByPhase::put);
+        response.timing = timingByPhase;
+      }
+
+      if (coreContainer.isZooKeeperAware()) {
+        log.trace("SplitCoreAPI: Create cloud descriptors for sub-shards of 
core");
+        for (SolrCore newcore : newCores) {
+          // the index of the core changed from empty to have some data, its 
term must be not zero
+          CloudDescriptor cd = 
newcore.getCoreDescriptor().getCloudDescriptor();
+          ZkShardTerms zkShardTerms =
+              coreContainer
+                  .getZkController()
+                  .getShardTerms(cd.getCollectionName(), cd.getShardId());
+          zkShardTerms.ensureHighestTermsAreNotZero();
+        }
+      }
+
+      // After the split has completed, someone (here?) should start the 
process of replaying the
+      // buffered updates.
+    } catch (Exception e) {
+      log.error("ERROR executing split: ", e);
+      throw e;
+    } finally {
+      if (splitReq != null) splitReq.close();
+      if (parentCore != null) parentCore.close();
+      if (newCores != null) {
+        for (SolrCore newCore : newCores) {
+          newCore.close();
+        }
+      }
+    }
+  }
+
+  private SolrCore getCoreOrThrow(String coreName) {
+    final SolrCore core = coreContainer.getCore(coreName);
+    if (core == null) {
+      throw new CoreNotFoundException(coreName);
+    }
+    return core;
+  }
+
+  /** Identifies a missing source core so the v1 adapter can retain its legacy 
status codes. */
+  public static class CoreNotFoundException extends SolrException {
+    private CoreNotFoundException(String coreName) {
+      super(ErrorCode.NOT_FOUND, "Unknown core " + coreName);
+    }
+  }
+
+  /**
+   * This is called when splitByPrefix is used. The overseer called us to get 
recommended splits
+   * taking into account actual document distribution over the hash space.
+   */
+  private void handleGetRanges(String coreName, SplitCoreResponse response) 
throws Exception {
+    SolrCore parentCore = getCoreOrThrow(coreName);
+    RefCounted<SolrIndexSearcher> searcherHolder = 
parentCore.getRealtimeSearcher();
+
+    try {
+      if (!coreContainer.isZooKeeperAware()) {
+        throw new SolrException(
+            SolrException.ErrorCode.BAD_REQUEST, "Shard splitByPrefix requires 
SolrCloud mode.");
+      } else {
+        SolrIndexSearcher searcher = searcherHolder.get();
+
+        String routeFieldName = null;
+        String prefixField = "id_prefix";
+
+        ClusterState clusterState = 
coreContainer.getZkController().getClusterState();
+        String collectionName =
+            
parentCore.getCoreDescriptor().getCloudDescriptor().getCollectionName();
+        DocCollection collection = clusterState.getCollection(collectionName);
+        String sliceName = 
parentCore.getCoreDescriptor().getCloudDescriptor().getShardId();
+        Slice slice = collection.getSlice(sliceName);
+        CompositeIdRouter router =
+            (CompositeIdRouter)
+                (collection.getRouter() != null ? collection.getRouter() : 
DocRouter.DEFAULT);
+        DocRouter.Range currentRange = slice.getRange();
+
+        Object routerObj =
+            collection.get(CollectionStateProps.DOC_ROUTER); // for 
back-compat with Solr 4.4
+        if (routerObj instanceof Map<?, ?> routerProps) {
+          routeFieldName = (String) routerProps.get("field");
+        }
+        if (routeFieldName == null) {
+          routeFieldName = searcher.getSchema().getUniqueKeyField().getName();
+        }
+
+        Collection<RangeCount> counts = getHashHistogram(searcher, 
prefixField, router, collection);
+
+        if (counts.size() == 0) {
+          // How to determine if we should look at the id field to figure out 
the prefix buckets?
+          // There may legitimately be no indexed terms in id_prefix if no ids 
have a prefix yet.
+          // For now, avoid using splitByPrefix unless you are actually using 
prefixes.
+          counts =
+              getHashHistogramFromId(
+                  searcher, 
searcher.getSchema().getUniqueKeyField().getName(), router, collection);
+        }
+
+        Collection<DocRouter.Range> splits = getSplits(counts, currentRange);
+        String splitString = toSplitString(splits);
+
+        if (splitString == null) {
+          return;
+        }
+
+        response.ranges = splitString;
+      }
+    } finally {
+      searcherHolder.decref();
+      parentCore.close();
+    }
+  }
+
+  static class RangeCount implements Comparable<RangeCount> {
+    DocRouter.Range range;
+    int count;
+
+    public RangeCount(DocRouter.Range range, int count) {
+      this.range = range;
+      this.count = count;
+    }
 
-  private final CoreAdminHandler coreHandler;
+    @Override
+    public int hashCode() {
+      return range.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      if (!(obj instanceof RangeCount)) return false;
+      return this.range.equals(((RangeCount) obj).range);
+    }
 
-  public SplitCoreAPI(CoreAdminHandler coreHandler) {
-    this.coreHandler = coreHandler;
+    @Override
+    public int compareTo(RangeCount o) {
+      return this.range.compareTo(o.range);
+    }
+
+    @Override
+    public String toString() {
+      return range.toString() + "=" + count;
+    }
   }
 
-  @Command(name = V2_SPLIT_CORE_CMD)
-  public void splitCore(PayloadObj<SplitCorePayload> obj) throws Exception {
-    final SplitCorePayload v2Body = obj.get();
-    final Map<String, Object> v1Params = Utils.convertToMap(v2Body, new 
HashMap<>());
-    v1Params.put(
-        CoreAdminParams.ACTION,
-        CoreAdminParams.CoreAdminAction.SPLIT.name().toLowerCase(Locale.ROOT));
-    v1Params.put(
-        CoreAdminParams.CORE, 
obj.getRequest().getPathTemplateValues().get(CoreAdminParams.CORE));
+  static String toSplitString(Collection<DocRouter.Range> splits) throws 
Exception {
+    if (splits == null) {
+      return null;
+    }
 
-    if (v2Body.path != null && !v2Body.path.isEmpty()) {
-      v1Params.put(PATH, v2Body.path.toArray(new String[0]));
+    StringBuilder sb = new StringBuilder();
+    for (DocRouter.Range range : splits) {
+      if (sb.length() > 0) {
+        sb.append(",");
+      }
+      sb.append(range);
     }
-    if (v2Body.targetCore != null && !v2Body.targetCore.isEmpty()) {
-      v1Params.put(TARGET_CORE, v2Body.targetCore.toArray(new String[0]));
+
+    return sb.toString();
+  }
+
+  /*
+   * Returns a list of range counts sorted by the range lower bound
+   */
+  static Collection<RangeCount> getHashHistogram(
+      SolrIndexSearcher searcher,
+      String prefixField,
+      CompositeIdRouter router,
+      DocCollection collection)
+      throws IOException {
+    RTimer timer = new RTimer();
+    TreeMap<DocRouter.Range, RangeCount> counts = new TreeMap<>();
+
+    Terms terms = MultiTerms.getTerms(searcher.getIndexReader(), prefixField);
+    if (terms == null) {
+      return counts.values();
     }
 
-    if (v2Body.splitKey != null) {
-      v1Params.put(SPLIT_KEY, v1Params.remove("splitKey"));
+    int numPrefixes = 0;
+    int numTriLevel = 0;
+    int numCollisions = 0;
+    long sumBuckets = 0;
+
+    TermsEnum termsEnum = terms.iterator();
+    BytesRef term;
+    while ((term = termsEnum.next()) != null) {
+      numPrefixes++;
+
+      // truncate to first separator since we don't support multiple levels 
currently
+      // NOTE: this does not currently work for tri-level composite ids since 
the number of bits
+      // allocated to the first ID is 16 for a 2 part id and 8 for a 3 part id!
+      String termStr;
+      int routeKeyLen = router.getRouteKeyWithSeparator(term.bytes, 
term.offset, term.length);
+      if (routeKeyLen == 0 || routeKeyLen == term.length) {
+        termStr = term.utf8ToString();
+      } else {
+        int prevLen = term.length;
+        term.length = routeKeyLen;
+        termStr = term.utf8ToString();
+        term.length = prevLen; // restore    (Question: must we do this?)
+      }
+
+      DocRouter.Range range = router.getSearchRangeSingle(termStr, null, 
collection);
+      int numDocs = termsEnum.docFreq();
+      sumBuckets += numDocs;
+
+      RangeCount rangeCount = new RangeCount(range, numDocs);
+
+      RangeCount prev = counts.put(rangeCount.range, rangeCount);
+      if (prev != null) {
+        // we hit a hash collision or truncated a prefix to first level, so 
add the buckets
+        // together.
+        rangeCount.count += prev.count;
+        numCollisions++;
+      }
     }
 
-    coreHandler.handleRequestBody(wrapParams(obj.getRequest(), v1Params), 
obj.getResponse());
+    if (log.isInfoEnabled()) {
+      log.info(
+          "Split histogram: ms={}, numBuckets={} sumBuckets={} numPrefixes={} 
numTriLevel={} numCollisions={}",
+          timer.getTime(),
+          counts.size(),
+          sumBuckets,
+          numPrefixes,
+          numTriLevel,
+          numCollisions);
+    }
+
+    return counts.values();
   }
 
-  public static class SplitCorePayload implements ReflectMapWriter {
-    @JsonProperty public List<String> path;
+  /**
+   * Returns a list of range counts sorted by the range lower bound, using the 
indexed "id" field
+   * (i.e. the terms are full IDs, not just prefixes)
+   */
+  static Collection<RangeCount> getHashHistogramFromId(
+      SolrIndexSearcher searcher,
+      String idField,
+      CompositeIdRouter router,
+      DocCollection collection)
+      throws IOException {
+    RTimer timer = new RTimer();
+
+    TreeMap<DocRouter.Range, RangeCount> counts = new TreeMap<>();
+
+    Terms terms = MultiTerms.getTerms(searcher.getIndexReader(), idField);
+    if (terms == null) {
+      return counts.values();
+    }
+
+    int numPrefixes = 0;
+    int numCollisions = 0;
+    long sumBuckets = 0;
+
+    TermsEnum termsEnum = terms.iterator();
+    BytesRef currPrefix = new BytesRef(); // prefix of the previous "id" term 
WITH SEPARATOR
+    int bucketCount = 0; // count of the number of docs in the current bucket
+
+    // We're going to iterate over all terms, so do the minimum amount of work 
per term.
+    // Terms are sorted, so all terms sharing a prefix will be grouped 
together.  The extra work
+    // is really just limited to stepping over all the terms in the id field.
+    for (; ; ) {
+      BytesRef term = termsEnum.next();
+
+      // compare to current prefix bucket and see if this new term shares the 
same prefix
+      if (term != null && currPrefix.length > 0) {
+        // since currPrefix includes the trailing separator, we can assume 
startsWith is a
+        // sufficient test
+        if (StringHelper.startsWith(term, currPrefix)) {
+          bucketCount++; // use 1 since we are dealing with unique ids
+          continue;
+        }
+      }
 
-    @JsonProperty public List<String> targetCore;
+      // At this point the prefix did not match, so if we had a bucket we were 
working on, record
+      // it.
+      if (currPrefix.length > 0) {
+        numPrefixes++;
+        sumBuckets += bucketCount;
+        String currPrefixStr = currPrefix.utf8ToString();
+        DocRouter.Range range = router.getSearchRangeSingle(currPrefixStr, 
null, collection);
 
-    @JsonProperty public String splitKey;
+        RangeCount rangeCount = new RangeCount(range, bucketCount);
+        bucketCount = 0;
 
-    @JsonProperty public String splitMethod;
+        RangeCount prev = counts.put(rangeCount.range, rangeCount);
+        if (prev != null) {
+          // we hit a hash collision, so add the buckets together.
+          rangeCount.count += prev.count;
+          numCollisions++;
+        }
+      }
+
+      // if the current term is null, we ran out of values
+      if (term == null) break;
+
+      // find the new prefix (if any), with trailing separator
+      currPrefix.length = router.getRouteKeyWithSeparator(term.bytes, 
term.offset, term.length);
+      if (currPrefix.length > 0) {
+        // resize if needed
+        if (currPrefix.length > currPrefix.bytes.length) {
+          currPrefix.bytes = new byte[currPrefix.length + 10];
+        }
+        System.arraycopy(term.bytes, term.offset, currPrefix.bytes, 0, 
currPrefix.length);
+
+        bucketCount++;
+      }
+    }
+
+    if (log.isInfoEnabled()) {
+      log.info(
+          "Split histogram from idField {}: ms={}, numBuckets={} sumBuckets={} 
numPrefixes={} numCollisions={}",
+          idField,
+          timer.getTime(),
+          counts.size(),
+          sumBuckets,
+          numPrefixes,
+          numCollisions);
+    }
+
+    return counts.values();
+  }
+
+  /*
+   * Returns the list of recommended splits, or null if there is not enough 
information
+   */
+  static Collection<DocRouter.Range> getSplits(
+      Collection<RangeCount> rawCounts, DocRouter.Range currentRange) throws 
Exception {
+    int totalCount = 0;
+    // keep track of the largest in case we need to split it out into it's own 
shard
+    RangeCount biggest = null;
+    RangeCount last = null; // keep track of what the last range is
+
+    // Remove counts that don't overlap with currentRange (can happen if 
someone overrode document
+    // routing)
+    List<RangeCount> counts = new ArrayList<>(rawCounts.size());
+    for (RangeCount rangeCount : rawCounts) {
+      if (!rangeCount.range.overlaps(currentRange)) {
+        continue;
+      }
+      totalCount += rangeCount.count;
+      if (biggest == null || rangeCount.count > biggest.count) {
+        biggest = rangeCount;
+      }
+      counts.add(rangeCount);
+      last = rangeCount;
+    }
+
+    if (counts.size() == 0) {
+      // we don't have any data to go off of, so do the split the normal way
+      return null;
+    }
+
+    List<DocRouter.Range> targetRanges = new ArrayList<>();
+
+    if (counts.size() == 1) {
+      // We have a single range, so we should split it.
+      // Currently, we only split a prefix/bucket when we have just one, but 
this could be
+      // changed/controlled in the future via a allowedSizeDifference 
parameter (i.e. if just
+      // separating prefix buckets results in too large of an imbalanced, 
allow splitting within a
+      // prefix)
+
+      // It may already be a partial range, so figure that out
+      int lower = Math.max(last.range.min, currentRange.min);
+      int upper = Math.min(last.range.max, currentRange.max);
+      int mid = lower + (upper - lower) / 2;
+      if (mid == lower || mid == upper) {
+        // shard too small... this should pretty much never happen, but use 
default split logic if
+        // it does.
+        return null;
+      }
+
+      // Make sure to include the shard's current range in the new ranges so 
we don't create useless
+      // empty shards.
+      DocRouter.Range lowerRange = new DocRouter.Range(currentRange.min, mid);
+      DocRouter.Range upperRange = new DocRouter.Range(mid + 1, 
currentRange.max);
+      targetRanges.add(lowerRange);
+      targetRanges.add(upperRange);
+
+      return targetRanges;
+    }
+
+    // We have at least two ranges, so we want to partition the ranges
+    // and avoid splitting any individual range.
+    // The "middle" bucket we are going to find will be included with the 
lower range and excluded
+    // from the upper range.
+
+    int targetCount = totalCount / 2;
+    RangeCount middle = null;
+    RangeCount prev = null;
+    int currCount = 0;
+    for (RangeCount rangeCount : counts) {
+      currCount += rangeCount.count;
+      if (currCount >= targetCount) { // this should at least be true on the 
last range
+        middle = rangeCount;
+        break;
+      }
+      prev = rangeCount;
+    }
+
+    // check if using the range before the middle one would make a better 
split point
+    int overError = currCount - targetCount; // error if we include middle in 
first split
+    int underError =
+        targetCount - (currCount - middle.count); // error if we include 
middle in second split
+    if (underError < overError) {
+      middle = prev;
+    }
 
-    @JsonProperty public Boolean getRanges;
+    // The middle should never be the last, since that means that we won't 
actually do a split.
+    // Minimising the error (above) should already ensure this never happens.
+    assert !Objects.equals(middle, last);
 
-    @JsonProperty public String ranges;
+    // Make sure to include the shard's current range in the new ranges so we 
don't create useless
+    // empty shards.
+    DocRouter.Range lowerRange = new DocRouter.Range(currentRange.min, 
middle.range.max);
+    DocRouter.Range upperRange = new DocRouter.Range(middle.range.max + 1, 
currentRange.max);
+    targetRanges.add(lowerRange);
+    targetRanges.add(upperRange);
 
-    @JsonProperty public String async;
+    return targetRanges;
   }
 }
diff --git 
a/solr/core/src/test/org/apache/solr/handler/admin/api/SplitCoreAPITest.java 
b/solr/core/src/test/org/apache/solr/handler/admin/api/SplitCoreAPITest.java
new file mode 100644
index 00000000000..c2c822fc29e
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/SplitCoreAPITest.java
@@ -0,0 +1,216 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.SolrTestCaseJ4.DEFAULT_TEST_CORENAME;
+import static org.apache.solr.SolrTestCaseJ4.params;
+import static org.apache.solr.SolrTestCaseJ4.sdoc;
+import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP;
+import static org.hamcrest.Matchers.containsString;
+
+import java.time.Duration;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.solr.SolrTestCase;
+import org.apache.solr.client.api.model.GetNodeCommandStatusResponse;
+import org.apache.solr.client.solrj.RemoteSolrException;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.request.CoresApi;
+import org.apache.solr.client.solrj.request.GenericSolrRequest;
+import org.apache.solr.client.solrj.request.NodeApi;
+import org.apache.solr.common.util.EnvUtils;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.TimeSource;
+import org.apache.solr.util.ExternalPaths;
+import org.apache.solr.util.SolrJettyTestRule;
+import org.apache.solr.util.TimeOut;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+/** Tests for the split core V2 endpoint via the generated SolrJ client. */
+public class SplitCoreAPITest extends SolrTestCase {
+
+  private static final Duration ASYNC_SPLIT_TIMEOUT = Duration.ofSeconds(30);
+
+  @ClassRule public static SolrJettyTestRule solrTestRule = new 
SolrJettyTestRule();
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    EnvUtils.setProperty(
+        ALLOW_PATHS_SYSPROP, 
ExternalPaths.SERVER_HOME.toAbsolutePath().toString());
+    solrTestRule.startSolr(createTempDir());
+    solrTestRule
+        .newCollection(DEFAULT_TEST_CORENAME)
+        .withConfigSet(ExternalPaths.DEFAULT_CONFIGSET)
+        .create();
+  }
+
+  @Test
+  public void testSplitWithNoTargetCoreOrPathReturnsError() throws Exception {
+    var request = new CoresApi.SplitCore(DEFAULT_TEST_CORENAME);
+
+    final var ex =
+        expectThrows(
+            RemoteSolrException.class, () -> 
request.process(solrTestRule.getSolrClient()));
+    assertEquals(400, ex.code());
+    assertTrue(
+        "Expected error about missing targetCore or path",
+        ex.getMessage().contains("path") || 
ex.getMessage().contains("targetCore"));
+  }
+
+  @Test
+  public void testSplitIntoTargetCores() throws Exception {
+    final String sourceCore = "split-source";
+    final var targets = createSplitCores(sourceCore);
+
+    final var request = new CoresApi.SplitCore(sourceCore);
+    request.setTargetCore(targets);
+    final var response = request.process(solrTestRule.getAdminClient());
+    assertEquals(0, response.responseHeader.status);
+    assertNull(response.requestId);
+    assertNotNull(response.timing);
+    assertTrue(response.timing.get("time") instanceof Number);
+    assertTrue(response.timing.get("doSplit") instanceof Map<?, ?>);
+    assertSplitDocuments(targets);
+  }
+
+  private void assertSplitDocuments(List<String> targets) throws Exception {
+    long totalDocuments = 0;
+    for (String target : targets) {
+      try (var client = solrTestRule.getSolrClient(target)) {
+        client.commit();
+        totalDocuments += client.query(params("q", "*:*", "rows", 
"0")).getResults().getNumFound();
+      }
+    }
+    assertEquals(3, totalDocuments);
+  }
+
+  private List<String> createSplitCores(String sourceCore) throws Exception {
+    final var targets = List.of(sourceCore + "-target-1", sourceCore + 
"-target-2");
+    for (String coreName : List.of(sourceCore, targets.get(0), 
targets.get(1))) {
+      
solrTestRule.newCollection(coreName).withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();
+    }
+    try (var client = solrTestRule.getSolrClient(sourceCore)) {
+      client.add(List.of(sdoc("id", "1"), sdoc("id", "2"), sdoc("id", "3")));
+      client.commit();
+    }
+    return targets;
+  }
+
+  @Test
+  public void testUnknownCoreReturnsNotFound() {
+    for (boolean getRanges : List.of(false, true)) {
+      final var request = new CoresApi.SplitCore("missing-source");
+      request.setTargetCore(List.of(DEFAULT_TEST_CORENAME));
+      request.setGetRanges(getRanges);
+      final var error =
+          expectThrows(
+              RemoteSolrException.class, () -> 
request.process(solrTestRule.getAdminClient()));
+      assertEquals(404, error.code());
+      assertThat(error.getMessage(), containsString("Unknown core 
missing-source"));
+    }
+  }
+
+  @Test
+  public void testV1UnknownCoreKeepsLegacyStatus() {
+    for (boolean getRanges : List.of(false, true)) {
+      final var parameters =
+          params(
+              "action",
+              "SPLIT",
+              "core",
+              "missing-source",
+              "targetCore",
+              DEFAULT_TEST_CORENAME,
+              "getRanges",
+              Boolean.toString(getRanges));
+      final var request =
+          new GenericSolrRequest(
+              SolrRequest.METHOD.GET,
+              "/admin/cores",
+              SolrRequest.SolrRequestType.ADMIN,
+              parameters);
+      final var error =
+          expectThrows(
+              RemoteSolrException.class, () -> 
request.process(solrTestRule.getAdminClient()));
+      assertEquals(getRanges ? 400 : 500, error.code());
+    }
+  }
+
+  @Test
+  public void testV1SplitResponseKeepsLegacyTiming() throws Exception {
+    final String sourceCore = "legacy-split-source";
+    final var targets = createSplitCores(sourceCore);
+    final var parameters = params("action", "SPLIT", "core", sourceCore);
+    parameters.add("targetCore", targets.toArray(String[]::new));
+    final var request =
+        new GenericSolrRequest(
+            SolrRequest.METHOD.GET, "/admin/cores", 
SolrRequest.SolrRequestType.ADMIN, parameters);
+    final var response = 
request.process(solrTestRule.getAdminClient()).getResponse();
+    assertNull(response.get("timing"));
+    assertNull(response.get("requestid"));
+    assertNotNull(((NamedList<?>) response.get("response")).get("timing"));
+    assertSplitDocuments(targets);
+  }
+
+  @Test
+  public void testAsyncSplitReturnsRequestId() throws Exception {
+    final String sourceCore = "async-split-source";
+    final var targets = createSplitCores(sourceCore);
+    final String requestId = "split-request-" + random().nextLong();
+    final var request = new CoresApi.SplitCore(sourceCore);
+    request.setTargetCore(targets);
+    request.setAsync(requestId);
+    final var response = request.process(solrTestRule.getAdminClient());
+    assertEquals(requestId, response.requestId);
+
+    final var status = new AtomicReference<GetNodeCommandStatusResponse>();
+    new TimeOut(ASYNC_SPLIT_TIMEOUT, TimeSource.NANO_TIME)
+        .waitFor(
+            "Split task did not complete",
+            () -> {
+              try {
+                status.set(
+                    new 
NodeApi.GetCommandStatus(requestId).process(solrTestRule.getAdminClient()));
+                assertNotEquals("failed", status.get().status);
+                return "completed".equals(status.get().status);
+              } catch (Exception e) {
+                throw new AssertionError(e);
+              }
+            });
+    assertNotNull(((Map<?, ?>) status.get().response).get("timing"));
+    assertSplitDocuments(targets);
+  }
+
+  @Test
+  public void testGetRangesWithAsyncDoesNotEnqueueTask() throws Exception {
+    final String requestId = "split-ranges-" + random().nextLong();
+    final var request = new CoresApi.SplitCore(DEFAULT_TEST_CORENAME);
+    request.setGetRanges(true);
+    request.setAsync(requestId);
+    final var error =
+        expectThrows(
+            RemoteSolrException.class, () -> 
request.process(solrTestRule.getAdminClient()));
+    assertEquals(400, error.code());
+    assertThat(error.getMessage(), containsString("requires SolrCloud mode"));
+    assertEquals(
+        "notfound",
+        new 
NodeApi.GetCommandStatus(requestId).process(solrTestRule.getAdminClient()).status);
+  }
+}
diff --git 
a/solr/core/src/test/org/apache/solr/handler/admin/SplitHandlerTest.java 
b/solr/core/src/test/org/apache/solr/handler/admin/api/SplitHandlerTest.java
similarity index 73%
rename from 
solr/core/src/test/org/apache/solr/handler/admin/SplitHandlerTest.java
rename to 
solr/core/src/test/org/apache/solr/handler/admin/api/SplitHandlerTest.java
index 011f5fe3885..ccf15f93045 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/SplitHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/SplitHandlerTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.solr.handler.admin;
+package org.apache.solr.handler.admin.api;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -120,14 +120,15 @@ public class SplitHandlerTest extends SolrTestCaseJ4 {
       }
     }
 
-    List<SplitOp.RangeCount> counts = new ArrayList<>(maxRanges);
+    List<SplitCoreAPI.RangeCount> counts = new ArrayList<>(maxRanges);
     for (; ; ) {
       int end = start + rand.nextInt(100) + 1;
       if (end < start) {
         // overflow
         end = Integer.MAX_VALUE;
       }
-      counts.add(new SplitOp.RangeCount(new DocRouter.Range(start, end), 
rand.nextInt(1000) + 1));
+      counts.add(
+          new SplitCoreAPI.RangeCount(new DocRouter.Range(start, end), 
rand.nextInt(1000) + 1));
       if (counts.size() >= maxRanges) break;
       if (counts.size() == maxRanges / 2 && rand.nextBoolean()) {
         // transition toward the end of the range (more boundary cases for 
large ranges)
@@ -146,7 +147,7 @@ public class SplitHandlerTest extends SolrTestCaseJ4 {
     }
 
     try {
-      Collection<DocRouter.Range> results = SplitOp.getSplits(counts, curr);
+      Collection<DocRouter.Range> results = SplitCoreAPI.getSplits(counts, 
curr);
       verifyContiguous(results, curr);
     } catch (Throwable e) {
       // System.err.println(e);
@@ -158,17 +159,17 @@ public class SplitHandlerTest extends SolrTestCaseJ4 {
 
     // split whole range exactly in two
     DocRouter.Range curr = new DocRouter.Range(10, 15);
-    List<SplitOp.RangeCount> counts = new ArrayList<>();
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(10, 15), 100));
-    Collection<DocRouter.Range> results = SplitOp.getSplits(counts, curr);
+    List<SplitCoreAPI.RangeCount> counts = new ArrayList<>();
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(10, 15), 100));
+    Collection<DocRouter.Range> results = SplitCoreAPI.getSplits(counts, curr);
     assertEquals(12, results.iterator().next().max);
     verifyContiguous(results, curr);
 
     // make sure range with docs is split in half even if current range of 
shard is bigger
     curr = new DocRouter.Range(-100, 101);
     counts = new ArrayList<>();
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(10, 15), 100));
-    results = SplitOp.getSplits(counts, curr);
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(10, 15), 100));
+    results = SplitCoreAPI.getSplits(counts, curr);
     assertEquals(12, results.iterator().next().max);
     verifyContiguous(results, curr);
 
@@ -176,12 +177,12 @@ public class SplitHandlerTest extends SolrTestCaseJ4 {
     // this can happen since document routing can be overridden.
     curr = new DocRouter.Range(-100, 101);
     counts = new ArrayList<>();
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(-1000, -990), 100));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(-980, -970), 2));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(10, 15), 100));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(1000, 1010), 5));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(1020, 1030), 7));
-    results = SplitOp.getSplits(counts, curr);
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(-1000, -990), 
100));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(-980, -970), 
2));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(10, 15), 100));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(1000, 1010), 
5));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(1020, 1030), 
7));
+    results = SplitCoreAPI.getSplits(counts, curr);
     assertEquals(12, results.iterator().next().max);
     verifyContiguous(results, curr);
 
@@ -192,29 +193,29 @@ public class SplitHandlerTest extends SolrTestCaseJ4 {
     // The random tests *should* catch this as well though.
     curr = new DocRouter.Range(-100, 101);
     counts = new ArrayList<>();
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(0, 9), 1));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(10, 19), 4));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(20, 29), 3));
-    results = SplitOp.getSplits(counts, curr);
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(0, 9), 1));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(10, 19), 4));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(20, 29), 3));
+    results = SplitCoreAPI.getSplits(counts, curr);
     assertEquals(19, results.iterator().next().max);
     verifyContiguous(results, curr);
 
     curr = new DocRouter.Range(-100, 101);
     counts = new ArrayList<>();
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(0, 9), 3));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(10, 19), 4));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(20, 29), 1));
-    results = SplitOp.getSplits(counts, curr);
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(0, 9), 3));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(10, 19), 4));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(20, 29), 1));
+    results = SplitCoreAPI.getSplits(counts, curr);
     assertEquals(9, results.iterator().next().max);
     verifyContiguous(results, curr);
 
     // test that if largest count is first
     curr = new DocRouter.Range(-100, 101);
     counts = new ArrayList<>();
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(0, 9), 4));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(10, 19), 1));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(20, 29), 1));
-    results = SplitOp.getSplits(counts, curr);
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(0, 9), 4));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(10, 19), 1));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(20, 29), 1));
+    results = SplitCoreAPI.getSplits(counts, curr);
     assertEquals(9, results.iterator().next().max);
     verifyContiguous(results, curr);
 
@@ -222,10 +223,10 @@ public class SplitHandlerTest extends SolrTestCaseJ4 {
     // until the last range and then need to back up)
     curr = new DocRouter.Range(-100, 101);
     counts = new ArrayList<>();
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(0, 9), 1));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(10, 19), 1));
-    counts.add(new SplitOp.RangeCount(new DocRouter.Range(20, 29), 4));
-    results = SplitOp.getSplits(counts, curr);
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(0, 9), 1));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(10, 19), 1));
+    counts.add(new SplitCoreAPI.RangeCount(new DocRouter.Range(20, 29), 4));
+    results = SplitCoreAPI.getSplits(counts, curr);
     assertEquals(19, results.iterator().next().max);
     verifyContiguous(results, curr);
   }
@@ -245,10 +246,10 @@ public class SplitHandlerTest extends SolrTestCaseJ4 {
       SolrQueryRequest req = req("myquery");
       try {
         // the first time through the loop we do this before adding docs to 
test an empty index
-        Collection<SplitOp.RangeCount> counts1 =
-            SplitOp.getHashHistogram(req.getSearcher(), prefixField, router, 
null);
-        Collection<SplitOp.RangeCount> counts2 =
-            SplitOp.getHashHistogramFromId(req.getSearcher(), idField, router, 
null);
+        Collection<SplitCoreAPI.RangeCount> counts1 =
+            SplitCoreAPI.getHashHistogram(req.getSearcher(), prefixField, 
router, null);
+        Collection<SplitCoreAPI.RangeCount> counts2 =
+            SplitCoreAPI.getHashHistogramFromId(req.getSearcher(), idField, 
router, null);
         assertTrue(eqCount(counts1, counts2));
 
         if (i > 0) {
@@ -274,16 +275,17 @@ public class SplitHandlerTest extends SolrTestCaseJ4 {
     }
   }
 
-  private boolean eqCount(Collection<SplitOp.RangeCount> a, 
Collection<SplitOp.RangeCount> b) {
+  private boolean eqCount(
+      Collection<SplitCoreAPI.RangeCount> a, 
Collection<SplitCoreAPI.RangeCount> b) {
     if (a.size() != b.size()) {
       return false;
     }
 
-    Iterator<SplitOp.RangeCount> it1 = a.iterator();
-    Iterator<SplitOp.RangeCount> it2 = b.iterator();
+    Iterator<SplitCoreAPI.RangeCount> it1 = a.iterator();
+    Iterator<SplitCoreAPI.RangeCount> it2 = b.iterator();
     while (it1.hasNext()) {
-      SplitOp.RangeCount r1 = it1.next();
-      SplitOp.RangeCount r2 = it2.next();
+      SplitCoreAPI.RangeCount r1 = it1.next();
+      SplitCoreAPI.RangeCount r2 = it2.next();
       if (!r1.range.equals(r2.range) || r1.count != r2.count) {
         return false;
       }
diff --git 
a/solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java
 
b/solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java
index f33e0df9dc8..da508d08750 100644
--- 
a/solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java
+++ 
b/solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java
@@ -17,18 +17,11 @@
 
 package org.apache.solr.handler.admin.api;
 
-import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
-import static org.apache.solr.common.params.CommonAdminParams.SPLIT_KEY;
 import static org.apache.solr.common.params.CommonParams.ACTION;
-import static org.apache.solr.common.params.CommonParams.PATH;
 import static org.apache.solr.common.params.CoreAdminParams.CORE;
 import static org.apache.solr.common.params.CoreAdminParams.CORE_NODE_NAME;
 import static org.apache.solr.common.params.CoreAdminParams.NAME;
-import static org.apache.solr.common.params.CoreAdminParams.RANGES;
-import static org.apache.solr.common.params.CoreAdminParams.TARGET_CORE;
 
-import java.util.Arrays;
-import java.util.List;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.handler.admin.CoreAdminHandler;
@@ -61,7 +54,6 @@ public class V2CoreAPIMappingTest extends 
V2ApiMappingTest<CoreAdminHandler> {
   @Override
   public void populateApiBag() {
     final CoreAdminHandler handler = getRequestHandler();
-    apiBag.registerObject(new SplitCoreAPI(handler));
     apiBag.registerObject(new RequestCoreRecoveryAPI(handler));
     apiBag.registerObject(new PrepareCoreRecoveryAPI(handler));
     apiBag.registerObject(new RequestApplyCoreUpdatesAPI(handler));
@@ -69,34 +61,6 @@ public class V2CoreAPIMappingTest extends 
V2ApiMappingTest<CoreAdminHandler> {
     apiBag.registerObject(new RequestBufferUpdatesAPI(handler));
   }
 
-  @Test
-  public void testSplitCoreAllParams() throws Exception {
-    final SolrParams v1Params =
-        captureConvertedV1Params(
-            "/cores/coreName",
-            "POST",
-            "{"
-                + "\"split\": {"
-                + "\"path\": [\"path1\", \"path2\"], "
-                + "\"targetCore\": [\"core1\", \"core2\"], "
-                + "\"splitKey\": \"someSplitKey\", "
-                + "\"getRanges\": true, "
-                + "\"ranges\": \"range1,range2\", "
-                + "\"async\": \"someRequestId\"}}");
-
-    assertEquals("split", v1Params.get(ACTION));
-    assertEquals("coreName", v1Params.get(CORE));
-    assertEquals("someSplitKey", v1Params.get(SPLIT_KEY));
-    assertEquals("range1,range2", v1Params.get(RANGES));
-    assertEquals("someRequestId", v1Params.get(ASYNC));
-    final List<String> pathEntries = Arrays.asList(v1Params.getParams(PATH));
-    assertEquals(2, pathEntries.size());
-    assertTrue(pathEntries.containsAll(List.of("path1", "path2")));
-    final List<String> targetCoreEntries = 
Arrays.asList(v1Params.getParams(TARGET_CORE));
-    assertEquals(2, targetCoreEntries.size());
-    assertTrue(targetCoreEntries.containsAll(List.of("core1", "core2")));
-  }
-
   @Test
   public void testRequestCoreRecoveryAllParams() throws Exception {
     final SolrParams v1Params =
diff --git 
a/solr/solr-ref-guide/modules/configuration-guide/pages/coreadmin-api.adoc 
b/solr/solr-ref-guide/modules/configuration-guide/pages/coreadmin-api.adoc
index ad99d35f6e3..fea19b576b1 100644
--- a/solr/solr-ref-guide/modules/configuration-guide/pages/coreadmin-api.adoc
+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/coreadmin-api.adoc
@@ -671,8 +671,12 @@ Request ID to track this action which will be processed 
asynchronously.
 The `SPLIT` action splits an index into two or more indexes.
 The index being split can continue to handle requests.
 The split pieces can be placed into a specified directory on the server's 
filesystem or it can be merged into running Solr cores.
+See the <<SPLIT Examples>> below for sample V1 and V2 requests.
+The v2 response includes per-phase split measurements in `timing` after a 
synchronous split, and a `requestid` acknowledgement when `async` is supplied.
+Poll `GET /api/node/commands/{requestId}` to retrieve the result of an 
asynchronous split.
+Synchronous requests referencing an unknown source core return HTTP 404 in v2.
 
-The `SPLIT` action supports five parameters, which are described in the table 
below.
+The `SPLIT` action supports the following parameters.
 
 === SPLIT Parameters
 
@@ -684,6 +688,7 @@ s|Required |Default: none
 |===
 +
 The name of the core to be split.
+This parameter is required in v1, and part of the URL in the v2 API.
 
 `path`::
 +
@@ -718,7 +723,7 @@ A comma-separated list of hash ranges in hexadecimal format.
 If this parameter is used, `split.key` should not be.
 See the <<SPLIT Examples>> below for an example of how this parameter can be 
used.
 
-`split.key`::
+`split.key` (v1), `splitKey` (v2)::
 +
 [%autowidth,frame=none]
 |===
@@ -744,29 +749,119 @@ The `core` index will be split into as many pieces as 
the number of `path` or `t
 
 *Usage with two targetCore parameters*:
 
+[tabs#coreadmin-split-targetcore-request]
+======
+V1 API::
++
+====
 [source,bash]
+----
 
http://localhost:8983/solr/admin/cores?action=SPLIT&core=core0&targetCore=core1&targetCore=core2
+----
+====
+
+V2 API::
++
+====
+[source,bash]
+----
+curl -X POST http://localhost:8983/api/cores/core0/split -H 'Content-Type: 
application/json' -d '
+  {
+    "targetCore": ["core1", "core2"]
+  }
+'
+----
+====
+======
 
 Here the `core` index will be split into two pieces and merged into the two 
`targetCore` indexes.
 
 *Usage with two path parameters*:
 
+[tabs#coreadmin-split-path-request]
+======
+V1 API::
++
+====
 [source,bash]
+----
 
http://localhost:8983/solr/admin/cores?action=SPLIT&core=core0&path=/path/to/index/1&path=/path/to/index/2
+----
+====
+
+V2 API::
++
+====
+[source,bash]
+----
+curl -X POST http://localhost:8983/api/cores/core0/split -H 'Content-Type: 
application/json' -d '
+  {
+    "path": ["/path/to/index/1", "/path/to/index/2"]
+  }
+'
+----
+====
+======
 
 The `core` index will be split into two pieces and written into the two 
directory paths specified.
 
 *Usage with the split.key parameter*:
 
+[tabs#coreadmin-split-splitkey-request]
+======
+V1 API::
++
+====
 [source,bash]
+----
 
http://localhost:8983/solr/admin/cores?action=SPLIT&core=core0&targetCore=core1&split.key=A!
+----
+====
+
+V2 API::
++
+====
+[source,bash]
+----
+curl -X POST http://localhost:8983/api/cores/core0/split -H 'Content-Type: 
application/json' -d '
+  {
+    "targetCore": ["core1"],
+    "splitKey": "A!"
+  }
+'
+----
+====
+======
 
 Here all documents having the same route key as the `split.key` i.e., `A!` 
will be split from the `core` index and written to the `targetCore`.
 
 *Usage with ranges parameter*:
 
+[tabs#coreadmin-split-ranges-request]
+======
+V1 API::
++
+====
 [source,bash]
+----
 
http://localhost:8983/solr/admin/cores?action=SPLIT&core=core0&targetCore=core1&targetCore=core2&targetCore=core3&ranges=0-1f4,1f5-3e8,3e9-5dc
+----
+====
+
+V2 API::
++
+====
+[source,bash]
+----
+curl -X POST http://localhost:8983/api/cores/core0/split -H 'Content-Type: 
application/json' -d '
+  {
+    "targetCore": ["core1", "core2", "core3"],
+    "ranges": "0-1f4,1f5-3e8,3e9-5dc"
+  }
+'
+----
+====
+======
 
 This example uses the `ranges` parameter with hash ranges 0-500, 501-1000 and 
1001-1500 specified in hexadecimal.
 Here the index will be split into three pieces with each targetCore receiving 
documents matching the hash ranges specified i.e., core1 will get documents 
with hash range 0-500, core2 will receive documents with hash range 501-1000 
and finally, core3 will receive documents with hash range 1001-1500.

Reply via email to