Apache Solr open-source search software
SOLR-16893: Remove deprecated create_core and create_collection CLI commands. (#1818)
Eric Pugh5193a3bcd8f2
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 01998993311..d2fd1e5556e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -36,6 +36,8 @@ Deprecation Removals* SOLR-16823: Remove backcompatiblity of -upconfig and -downconfig for bin/solr zk upconfig and downconfig commands. (Eric Pugh)+* SOLR-16893: Remove bin/solr create_core and create_collection commands in favour of bin/solr create command. (Eric Pugh)+Dependency Upgrades---------------------(No changes)diff --git a/solr/bin/solr b/solr/bin/solrindex 396de287593..e78693bba29 100644--- a/solr/bin/solr+++ b/solr/bin/solr@@ -836,7 +836,7 @@ if [ "$SCRIPT_CMD" == "config" ]; thenfi# create a core or collection-if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMD" == "create_collection" ]]; then+if [[ "$SCRIPT_CMD" == "create" ]]; thenrun_tool $SCRIPT_CMD $@exit $?fidiff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex 7936998ef20..f133a45d471 100755--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -244,8 +244,6 @@ IF "%1"=="stop" goto set_script_cmdIF "%1"=="restart" goto set_script_cmdIF "%1"=="healthcheck" goto run_solrcliIF "%1"=="create" goto run_solrcli-IF "%1"=="create_core" goto run_solrcli-IF "%1"=="create_collection" goto run_solrcliIF "%1"=="delete" goto run_solrcliIF "%1"=="postlogs" goto run_solrcliIF "%1"=="zk" (@@ -276,8 +274,6 @@ IF "%SCRIPT_CMD%"=="restart" goto start_usageIF "%SCRIPT_CMD%"=="stop" goto stop_usageIF "%SCRIPT_CMD%"=="healthcheck" goto run_solrcliIF "%SCRIPT_CMD%"=="create" goto run_solrcli-IF "%SCRIPT_CMD%"=="create_core" goto run_solrcli-IF "%SCRIPT_CMD%"=="create_collection" goto run_solrcliIF "%SCRIPT_CMD%"=="delete" goto run_solrcliIF "%SCRIPT_CMD%"=="zk" goto zk_usageIF "%SCRIPT_CMD%"=="auth" goto auth_usage@@ -1637,10 +1633,6 @@ IF "%FIRST_ARG%"=="start" (goto run_solrcli) ELSE IF "%FIRST_ARG%"=="create" (goto run_solrcli-) ELSE IF "%FIRST_ARG%"=="create_core" (- goto run_solrcli-) ELSE IF "%FIRST_ARG%"=="create_collection" (- goto run_solrcli) ELSE IF "%FIRST_ARG%"=="zk" (goto zk_short_usage) ELSE IF "%FIRST_ARG%"=="auth" (diff --git a/solr/core/src/java/org/apache/solr/cli/CreateCollectionTool.java b/solr/core/src/java/org/apache/solr/cli/CreateCollectionTool.javadeleted file mode 100644index 48c4162dea8..00000000000--- a/solr/core/src/java/org/apache/solr/cli/CreateCollectionTool.java+++ /dev/null@@ -1,280 +0,0 @@-/*- * 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.cli;--import java.io.File;-import java.io.PrintStream;-import java.nio.file.Path;-import java.util.Collections;-import java.util.List;-import java.util.Locale;-import java.util.Optional;-import java.util.Set;-import org.apache.commons.cli.CommandLine;-import org.apache.commons.cli.Option;-import org.apache.solr.client.solrj.SolrServerException;-import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient;-import org.apache.solr.client.solrj.impl.CloudSolrClient;-import org.apache.solr.client.solrj.request.CollectionAdminRequest;-import org.apache.solr.common.cloud.ZkMaintenanceUtils;-import org.apache.solr.common.cloud.ZkStateReader;-import org.apache.solr.common.params.CollectionAdminParams;-import org.apache.solr.common.util.NamedList;-import org.apache.solr.core.ConfigSetService;-import org.noggit.CharArr;-import org.noggit.JSONWriter;--/**- * Supports create_collection command in the bin/solr script.- *- * @deprecated Please use {@link CreateTool}- */-@Deprecated(since = "9.4")-public class CreateCollectionTool extends ToolBase {-- public static final List<Option> CREATE_COLLECTION_OPTIONS =- List.of(- SolrCLI.OPTION_ZKHOST,- SolrCLI.OPTION_SOLRURL,- Option.builder("c")- .longOpt("name")- .argName("NAME")- .hasArg()- .required(true)- .desc("Name of collection to create.")- .build(),- Option.builder("s")- .longOpt("shards")- .argName("#")- .hasArg()- .required(false)- .desc("Number of shards; default is 1.")- .build(),- Option.builder("rf")- .longOpt("replicationFactor")- .argName("#")- .hasArg()- .required(false)- .desc(- "Number of copies of each document across the collection (replicas per shard); default is 1.")- .build(),- Option.builder("d")- .longOpt("confdir")- .argName("NAME")- .hasArg()- .required(false)- .desc(- "Configuration directory to copy when creating the new collection; default is "- + SolrCLI.DEFAULT_CONFIG_SET- + '.')- .build(),- Option.builder("n")- .longOpt("confname")- .argName("NAME")- .hasArg()- .required(false)- .desc("Configuration name; default is the collection name.")- .build(),- SolrCLI.OPTION_VERBOSE);-- public CreateCollectionTool() {- this(CLIO.getOutStream());- }-- public CreateCollectionTool(PrintStream stdout) {- super(stdout);- }-- @Override- public String getName() {- return "create_collection";- }-- @Override- public List<Option> getOptions() {- return CREATE_COLLECTION_OPTIONS;- }-- @Override- public void runImpl(CommandLine cli) throws Exception {- SolrCLI.raiseLogLevelUnlessVerbose(cli);- echo("This command has been deprecated in favour of using 'bin/solr create'.");- String zkHost = SolrCLI.getZkHost(cli);- if (zkHost == null) {- throw new IllegalStateException(- "Solr at is running in standalone server mode, please use the create_core command instead;\n"- + "create_collection can only be used when running in SolrCloud mode.\n");- }-- try (CloudHttp2SolrClient cloudSolrClient =- new CloudHttp2SolrClient.Builder(Collections.singletonList(zkHost), Optional.empty())- .build()) {- echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);- cloudSolrClient.connect();- runCloudTool(cloudSolrClient, cli);- }- }-- protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) throws Exception {-- String collectionName = cli.getOptionValue("name");- final String solrInstallDir = System.getProperty("solr.install.dir");- String confName = cli.getOptionValue("confname");- String confDir = cli.getOptionValue("confdir", "_default");- ensureConfDirExists(confDir, solrInstallDir);- printDefaultConfigsetWarningIfNecessary(cli);-- Set<String> liveNodes = cloudSolrClient.getClusterState().getLiveNodes();- if (liveNodes.isEmpty())- throw new IllegalStateException(- "No live nodes found! Cannot create a collection until "- + "there is at least 1 live node in the cluster.");-- String solrUrl = cli.getOptionValue("solrUrl");- if (solrUrl == null) {- String firstLiveNode = liveNodes.iterator().next();- solrUrl = ZkStateReader.from(cloudSolrClient).getBaseUrlForNodeName(firstLiveNode);- }-- // build a URL to create the collection- int numShards = Integer.parseInt(cli.getOptionValue("shards", String.valueOf(1)));- int replicationFactor =- Integer.parseInt(cli.getOptionValue("replicationFactor", String.valueOf(1)));-- final String configsetsDir = solrInstallDir + "/server/solr/configsets";-- boolean configExistsInZk =- confName != null- && !confName.trim().isEmpty()- && ZkStateReader.from(cloudSolrClient)- .getZkClient()- .exists("/configs/" + confName, true);-- if (CollectionAdminParams.SYSTEM_COLL.equals(collectionName)) {- // do nothing- } else if (configExistsInZk) {- echo("Re-using existing configuration directory " + confName);- } else { // if (confdir != null && !confdir.trim().isEmpty()) {- if (confName == null || confName.trim().isEmpty()) {- confName = collectionName;- }- Path confPath = ConfigSetService.getConfigsetPath(confDir, configsetsDir);-- echoIfVerbose(- "Uploading "- + confPath.toAbsolutePath()- + " for config "- + confName- + " to ZooKeeper at "- + cloudSolrClient.getClusterStateProvider().getQuorumHosts(),- cli);- ZkMaintenanceUtils.uploadToZK(- ZkStateReader.from(cloudSolrClient).getZkClient(),- confPath,- ZkMaintenanceUtils.CONFIGS_ZKNODE + "/" + confName,- ZkMaintenanceUtils.UPLOAD_FILENAME_EXCLUDE_PATTERN);- }-- // since creating a collection is a heavy-weight operation, check for existence first- if (SolrCLI.safeCheckCollectionExists(solrUrl, collectionName)) {- throw new IllegalStateException(- "\nCollection '"- + collectionName- + "' already exists!\nChecked collection existence using CollectionAdminRequest");- }-- // doesn't seem to exist ... try to create- echoIfVerbose(- "\nCreating new collection '" + collectionName + "' using CollectionAdminRequest", cli);-- NamedList<Object> response;- try {- response =- cloudSolrClient.request(- CollectionAdminRequest.createCollection(- collectionName, confName, numShards, replicationFactor));- } catch (SolrServerException sse) {- throw new Exception(- "Failed to create collection '" + collectionName + "' due to: " + sse.getMessage());- }-- if (cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt())) {- CharArr arr = new CharArr();- new JSONWriter(arr, 2).write(response.asMap());- echo(arr.toString());- } else {- String endMessage =- String.format(- Locale.ROOT,- "Created collection '%s' with %d shard(s), %d replica(s)",- collectionName,- numShards,- replicationFactor);- if (confName != null && !confName.trim().isEmpty()) {- endMessage += String.format(Locale.ROOT, " with config-set '%s'", confName);- }-- echo(endMessage);- }- }-- /**- * Ensure the confDirName is a path to a directory by itself or when it is combined with the- * solrInstallDir.- */- private void ensureConfDirExists(String confDirName, String solrInstallDir) {- if (!new File(confDirName).isDirectory()) {- final String fullConfDir = solrInstallDir + "/server/solr/configsets/" + confDirName;- if (!new File(fullConfDir).isDirectory()) {- echo("Specified configuration directory " + confDirName + " not found!");- System.exit(1);- }- }- }-- private void printDefaultConfigsetWarningIfNecessary(CommandLine cli) {- final String confDirectoryName = cli.getOptionValue("confdir", "_default"); // CREATE_CONFDIR- final String confName = cli.getOptionValue("confname", "");-- if (confDirectoryName.equals("_default")- && (confName.equals("") || confName.equals("_default"))) {- final String collectionName = cli.getOptionValue("name");- final String solrUrl = cli.getOptionValue("solrUrl");- final String curlCommand =- String.format(- Locale.ROOT,- "curl %s/%s/config -d "- + "'{\"set-user-property\": {\"update.autoCreateFields\":\"false\"}}'",- solrUrl,- collectionName);- final String configCommand =- String.format(- Locale.ROOT,- "bin/solr config -c %s -p 8983 -action set-user-property -property update.autoCreateFields -value false",- collectionName);- echo(- "WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is");- echo(" NOT RECOMMENDED for production use.");- echo("");- echo(" To turn it off:");- echo(" " + curlCommand);- echo(" Or:");- echo(" " + configCommand);- }- }-}diff --git a/solr/core/src/java/org/apache/solr/cli/CreateCoreTool.java b/solr/core/src/java/org/apache/solr/cli/CreateCoreTool.javadeleted file mode 100644index 0d1eeaa4364..00000000000--- a/solr/core/src/java/org/apache/solr/cli/CreateCoreTool.java+++ /dev/null@@ -1,206 +0,0 @@-/*- * 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.cli;--import java.io.File;-import java.io.IOException;-import java.io.PrintStream;-import java.util.List;-import java.util.Locale;-import java.util.Map;-import org.apache.commons.cli.CommandLine;-import org.apache.commons.cli.Option;-import org.apache.commons.io.FileUtils;-import org.apache.commons.io.file.PathUtils;-import org.apache.solr.client.solrj.SolrRequest;-import org.apache.solr.client.solrj.request.CoreAdminRequest;-import org.apache.solr.client.solrj.request.GenericSolrRequest;-import org.apache.solr.client.solrj.response.CoreAdminResponse;-import org.apache.solr.common.params.CommonParams;--/**- * Supports create command in the bin/solr script.- *- * @deprecated Please use {@link CreateTool}- */-@Deprecated(since = "9.4")-public class CreateCoreTool extends ToolBase {-- public CreateCoreTool() {- this(CLIO.getOutStream());- }-- public CreateCoreTool(PrintStream stdout) {- super(stdout);- }-- @Override- public String getName() {- return "create_core";- }-- @Override- public List<Option> getOptions() {- return List.of(- SolrCLI.OPTION_SOLRURL,- Option.builder("c")- .longOpt("name")- .argName("NAME")- .hasArg()- .required(true)- .desc("Name of the core to create.")- .build(),- Option.builder("d")- .longOpt("confdir")- .argName("NAME")- .hasArg()- .required(false)- .desc(- "Configuration directory to copy when creating the new core; default is "- + SolrCLI.DEFAULT_CONFIG_SET- + '.')- .build(),- // Option.builder("configsetsDir")- // .argName("DIR")- // .hasArg()- // .required(true)- // .desc("Path to configsets directory on the local system.")- // .build(),- SolrCLI.OPTION_VERBOSE);- }-- @Override- public void runImpl(CommandLine cli) throws Exception {- echo("This command has been deprecated in favour of using 'bin/solr create'.");- String coreName = cli.getOptionValue("name");- String solrUrl = cli.getOptionValue("solrUrl", SolrCLI.DEFAULT_SOLR_URL);-- final String solrInstallDir = System.getProperty("solr.install.dir");- final String confDirName =- cli.getOptionValue("confdir", SolrCLI.DEFAULT_CONFIG_SET); // CREATE_CONFDIR-- // we allow them to pass a directory instead of a configset name- File configsetDir = new File(confDirName);- if (!configsetDir.isDirectory()) {- ensureConfDirExists(confDirName, solrInstallDir);- }- printDefaultConfigsetWarningIfNecessary(cli);-- String coreRootDirectory; // usually same as solr home, but not always- try (var solrClient = SolrCLI.getSolrClient(solrUrl)) {- Map<String, Object> systemInfo =- solrClient- .request(- new GenericSolrRequest(SolrRequest.METHOD.GET, CommonParams.SYSTEM_INFO_PATH))- .asMap();- if ("solrcloud".equals(systemInfo.get("mode"))) {- throw new IllegalStateException(- "Solr at "- + solrUrl- + " is running in SolrCloud mode, please use create_collection command instead.");- }-- // convert raw JSON into user-friendly output- coreRootDirectory = (String) systemInfo.get("core_root");- }-- if (SolrCLI.safeCheckCoreExists(solrUrl, coreName)) {- throw new IllegalArgumentException(- "\nCore '"- + coreName- + "' already exists!\nChecked core existence using Core API command");- }-- File coreInstanceDir = new File(coreRootDirectory, coreName);- File confDir = new File(getFullConfDir(confDirName, solrInstallDir), "conf");- if (!coreInstanceDir.isDirectory()) {- coreInstanceDir.mkdirs();- if (!coreInstanceDir.isDirectory()) {- throw new IOException(- "Failed to create new core instance directory: " + coreInstanceDir.getAbsolutePath());- }-- FileUtils.copyDirectoryToDirectory(confDir, coreInstanceDir);-- echoIfVerbose(- "\nCopying configuration to new core instance directory:\n"- + coreInstanceDir.getAbsolutePath(),- cli);- }-- echoIfVerbose("\nCreating new core '" + coreName + "' using CoreAdminRequest", cli);-- try (var solrClient = SolrCLI.getSolrClient(solrUrl)) {- CoreAdminResponse res = CoreAdminRequest.createCore(coreName, coreName, solrClient);- if (cli.hasOption(SolrCLI.OPTION_VERBOSE.getOpt())) {- echo(res.jsonStr());- echo("\n");- } else {- echo(String.format(Locale.ROOT, "\nCreated new core '%s'", coreName));- }- } catch (Exception e) {- /* create-core failed, cleanup the copied configset before propagating the error. */- PathUtils.deleteDirectory(coreInstanceDir.toPath());- throw e;- }- }-- private String getFullConfDir(String confDirName, String solrInstallDir) {- return solrInstallDir + "/server/solr/configsets/" + confDirName;- }-- private String ensureConfDirExists(String confDirName, String solrInstallDir) {- String fullConfDir = getFullConfDir(confDirName, solrInstallDir);- if (!new File(fullConfDir).isDirectory()) {- echo("Specified configuration directory " + confDirName + " not found!");- System.exit(1);- }-- return fullConfDir;- }-- private void printDefaultConfigsetWarningIfNecessary(CommandLine cli) {- final String confDirectoryName = cli.getOptionValue("confdir", "_default"); // CREATE_CONFDIR- final String confName = cli.getOptionValue("confname", "");-- if (confDirectoryName.equals("_default")- && (confName.equals("") || confName.equals("_default"))) {- final String collectionName = cli.getOptionValue("collection");- final String solrUrl = cli.getOptionValue("solrUrl", SolrCLI.DEFAULT_SOLR_URL);- final String curlCommand =- String.format(- Locale.ROOT,- "curl %s/%s/config -d "- + "'{\"set-user-property\": {\"update.autoCreateFields\":\"false\"}}'",- solrUrl,- collectionName);- final String configCommand =- String.format(- Locale.ROOT,- "bin/solr config -c %s -p 8983 -action set-user-property -property update.autoCreateFields -value false",- collectionName);- echo(- "WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is");- echo(" NOT RECOMMENDED for production use.");- echo("");- echo(" To turn it off:");- echo(" " + curlCommand);- echo(" Or:");- echo(" " + configCommand);- }- }-}diff --git a/solr/core/src/java/org/apache/solr/cli/SolrCLI.java b/solr/core/src/java/org/apache/solr/cli/SolrCLI.javaindex 8a92e6801e9..c0a385a0198 100755--- a/solr/core/src/java/org/apache/solr/cli/SolrCLI.java+++ b/solr/core/src/java/org/apache/solr/cli/SolrCLI.java@@ -219,8 +219,6 @@ public class SolrCLI implements CLIO {if ("healthcheck".equals(toolType)) return new HealthcheckTool();else if ("status".equals(toolType)) return new StatusTool();else if ("api".equals(toolType)) return new ApiTool();- else if ("create_collection".equals(toolType)) return new CreateCollectionTool();- else if ("create_core".equals(toolType)) return new CreateCoreTool();else if ("create".equals(toolType)) return new CreateTool();else if ("delete".equals(toolType)) return new DeleteTool();else if ("config".equals(toolType)) return new ConfigTool();@@ -428,7 +426,7 @@ public class SolrCLI implements CLIO {print("Usage: solr COMMAND OPTIONS");print(- " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config, export, api, package, post");+ " where COMMAND is one of: start, stop, restart, status, healthcheck, create, delete, version, zk, auth, assert, config, export, api, package, post");print("");print(" Standalone server example (start Solr running in the background on port 8984):");print("");diff --git a/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java b/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.javaindex 29080392e98..03ccf37751b 100644--- a/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java@@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;import java.util.stream.Collectors;import java.util.stream.Stream;import org.apache.commons.cli.CommandLine;-import org.apache.solr.cli.CreateCollectionTool;+import org.apache.solr.cli.CreateTool;import org.apache.solr.cli.DeleteTool;import org.apache.solr.cli.HealthcheckTool;import org.apache.solr.cli.SolrCLI;@@ -96,7 +96,7 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {// NOTE: not calling SolrCLI.main as the script does because it calls System.exit which is a// no-no in a JUnit test- CreateCollectionTool tool = new CreateCollectionTool();+ CreateTool tool = new CreateTool();CommandLine cli = SolrCLI.processCommandLineArgs(tool.getName(), tool.getOptions(), args);log.info("Creating the '{}' collection using SolrCLI with: {}", testCollectionName, solrUrl);tool.runTool(cli);diff --git a/solr/docker/tests/cases/create_core_exec/test.sh b/solr/docker/tests/cases/create_core_exec/test.shindex 8f50832248a..6f423b85ab6 100755--- a/solr/docker/tests/cases/create_core_exec/test.sh+++ b/solr/docker/tests/cases/create_core_exec/test.sh@@ -25,7 +25,7 @@ docker run --name "$container_name" -d "$tag"wait_for_container_and_solr "$container_name"echo "Creating core"-docker exec --user=solr "$container_name" bin/solr create_core -c gettingstarted+docker exec --user=solr "$container_name" bin/solr create -c gettingstartedecho "Loading data"docker exec --user=solr "$container_name" bin/post -c gettingstarted example/exampledocs/manufacturers.xmlsleep 1diff --git a/solr/packaging/test/test_config.bats b/solr/packaging/test/test_config.batsindex b30ff762f0a..b588e0c10db 100644--- a/solr/packaging/test/test_config.bats+++ b/solr/packaging/test/test_config.bats@@ -39,14 +39,14 @@ teardown() {}@test "setting property" {- solr create_collection -c COLL_NAME+ solr create -c COLL_NAMErun solr config -c COLL_NAME -action set-property -property updateHandler.autoCommit.maxDocs -value 100 -solrUrl http://localhost:8983/solrassert_output --partial "Successfully set-property updateHandler.autoCommit.maxDocs to 100"}@test "short form of setting property" {- solr create_collection -c COLL_NAME+ solr create -c COLL_NAMErun solr config -c COLL_NAME -property updateHandler.autoCommit.maxDocs -value 100assert_output --partial "Successfully set-property updateHandler.autoCommit.maxDocs to 100"diff --git a/solr/packaging/test/test_export.bats b/solr/packaging/test/test_export.batsindex 699eba33911..6ddbe4d1880 100644--- a/solr/packaging/test/test_export.bats+++ b/solr/packaging/test/test_export.bats@@ -63,7 +63,7 @@ teardown() {@test "export fails on non cloud mode" {run solr start- run solr create_core -c COLL_NAME+ run solr create -c COLL_NAMErun solr export -url "http://localhost:8983/solr/COLL_NAME"refute_output --partial 'Export complete'assert_output --partial "ERROR: Couldn't initialize a HttpClusterStateProvider"diff --git a/solr/packaging/test/test_extraction.bats b/solr/packaging/test/test_extraction.batsindex 875f4ca2e59..def674b15d5 100644--- a/solr/packaging/test/test_extraction.bats+++ b/solr/packaging/test/test_extraction.bats@@ -38,7 +38,7 @@ teardown() {solr start -c -Dsolr.modules=extraction- solr create_collection -c gettingstarted -d _default+ solr create -c gettingstarted -d _defaultcurl -X POST -H 'Content-type:application/json' -d '{@@ -62,7 +62,7 @@ teardown() {export SOLR_SECURITY_MANAGER_ENABLED=falsesolr start -c -Dsolr.modules=extraction- solr create_collection -c content_extraction -d _default+ solr create -c content_extraction -d _defaultcurl -X POST -H 'Content-type:application/json' -d '{"add-requesthandler": {@@ -89,7 +89,7 @@ teardown() {export SOLR_SECURITY_MANAGER_ENABLED=falsesolr start -c -Dsolr.modules=extraction- solr create_collection -c website_extraction -d _default+ solr create -c website_extraction -d _defaultcurl -X POST -H 'Content-type:application/json' -d '{"add-requesthandler": {diff --git a/solr/packaging/test/test_help.bats b/solr/packaging/test/test_help.batsindex 304dff63a5e..c2fb863cd46 100644--- a/solr/packaging/test/test_help.bats+++ b/solr/packaging/test/test_help.bats@@ -68,18 +68,6 @@ setup() {refute_output --partial 'ERROR'}-@test "createcore help flag prints help" {- run solr create_core -help- assert_output --partial 'usage: create_core'- refute_output --partial 'ERROR'-}--@test "createcollection help flag prints help" {- run solr create_collection -help- assert_output --partial 'usage: create_collection'- refute_output --partial 'ERROR'-}-@test "delete help flag prints help" {run solr delete -helpassert_output --partial 'usage: delete'diff --git a/solr/packaging/test/test_modules.bats b/solr/packaging/test/test_modules.batsindex ff6d88c8041..ca9cf32acba 100644--- a/solr/packaging/test/test_modules.bats+++ b/solr/packaging/test/test_modules.bats@@ -31,7 +31,7 @@ teardown() {@test "SQL Module" {run solr start -c -Dsolr.modules=sql- run solr create_collection -c COLL_NAME+ run solr create -c COLL_NAMErun solr api -get http://localhost:8983/solr/COLL_NAME/sql?stmt=select+id+from+COLL_NAME+limit+10assert_output --partial '"docs":'assert_output --partial '"EOF":true'@@ -62,6 +62,6 @@ teardown() {@test "icu collation in analysis-extras module" {run solr start -c -Dsolr.modules=analysis-extras- run solr create_collection -c COLL_NAME -d test/analysis_extras_config/conf+ run solr create -c COLL_NAME -d test/analysis_extras_config/confassert_output --partial "Created collection 'COLL_NAME'"}diff --git a/solr/packaging/test/test_packages.bats b/solr/packaging/test/test_packages.batsindex 6d7359bb7fd..fd7410b5dd8 100644--- a/solr/packaging/test/test_packages.bats+++ b/solr/packaging/test/test_packages.bats@@ -50,7 +50,7 @@ teardown() {@test "deploying and undeploying of packages" {run solr start -c -Denable.packages=true- solr create_collection -c foo-1.2+ solr create -c foo-1.2# Deploy package - the package doesn't need to exist before the collection validation kicks inrun solr package deploy PACKAGE_NAME -collections foo-1.2diff --git a/solr/packaging/test/test_placement_plugin.bats b/solr/packaging/test/test_placement_plugin.batsindex 656c38e032d..375d8b4afc0 100644--- a/solr/packaging/test/test_placement_plugin.bats+++ b/solr/packaging/test/test_placement_plugin.bats@@ -32,7 +32,7 @@ teardown() {@test "Affinity placement plugin using sysprop" {run solr start -c -Dsolr.placementplugin.default=affinitysolr assert -c http://localhost:8983/solr -t 3000- run solr create_collection -c COLL_NAME+ run solr create -c COLL_NAMEcollection_exists COLL_NAMEassert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'Default replica placement plugin set in solr\.placementplugin\.default to affinity'}@@ -41,7 +41,7 @@ teardown() {export SOLR_PLACEMENTPLUGIN_DEFAULT=randomrun solr start -csolr assert -c http://localhost:8983/solr -t 3000- run solr create_collection -c COLL_NAME+ run solr create -c COLL_NAMEcollection_exists COLL_NAMEassert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'Default replica placement plugin set in solr\.placementplugin\.default to random'}diff --git a/solr/packaging/test/test_post.bats b/solr/packaging/test/test_post.batsindex 2b8c18bfe46..4a59d8c7aa8 100644--- a/solr/packaging/test/test_post.bats+++ b/solr/packaging/test/test_post.bats@@ -54,7 +54,7 @@ teardown() {@test "basic post with a type specified" {- run solr create_collection -c monitors -d _default+ run solr create -c monitors -d _defaultassert_output --partial "Created collection 'monitors'"run solr post -type application/xml -url http://localhost:8983/solr/monitors/update ${SOLR_TIP}/example/exampledocs/monitor.xml@@ -65,7 +65,7 @@ teardown() {@test "basic post WITHOUT a type specified" {- solr create_collection -c monitors_no_type -d _default+ solr create -c monitors_no_type -d _defaultrun solr post -url http://localhost:8983/solr/monitors_no_type/update -commit ${SOLR_TIP}/example/exampledocs/monitor.xml@@ -74,7 +74,7 @@ teardown() {run curl 'http://localhost:8983/solr/monitors_no_type/select?q=*:*'assert_output --partial '"numFound":1'- solr create_collection -c books_no_type -d _default+ solr create -c books_no_type -d _defaultrun solr post -url http://localhost:8983/solr/books_no_type/update -commit ${SOLR_TIP}/example/exampledocs/books.json@@ -83,7 +83,7 @@ teardown() {run curl 'http://localhost:8983/solr/books_no_type/select?q=*:*'assert_output --partial '"numFound":4'- solr create_collection -c books_csv_no_type -d _default+ solr create -c books_csv_no_type -d _defaultrun solr post -url http://localhost:8983/solr/books_csv_no_type/update -commit ${SOLR_TIP}/example/exampledocs/books.csv@@ -95,7 +95,7 @@ teardown() {@test "crawling a directory" {- solr create_collection -c mixed_content -d _default+ solr create -c mixed_content -d _default# We filter to xml,json,and csv as we don't want to invoke the Extract handler.run solr post -filetypes xml,json,csv -url http://localhost:8983/solr/mixed_content/update -commit ${SOLR_TIP}/example/exampledocs@@ -108,7 +108,7 @@ teardown() {# this test doesn't complete due to issues in posting to the /extract handler@test "crawling a web site" {- solr create_collection -c webcrawl -d _default+ solr create -c webcrawl -d _defaultcurl -X POST -H 'Content-type:application/json' -d '{"add-requesthandler": {@@ -124,7 +124,7 @@ teardown() {@test "commit and optimize and delete" {- run solr create_collection -c monitors2 -d _default+ run solr create -c monitors2 -d _defaultassert_output --partial "Created collection 'monitors2'"run solr post -url http://localhost:8983/solr/monitors2/update -type application/xml -commit -optimize ${SOLR_TIP}/example/exampledocs/monitor.xml@@ -138,7 +138,7 @@ teardown() {@test "args mode" {- run solr create_collection -c test_args -d _default+ run solr create -c test_args -d _defaultassert_output --partial "Created collection 'test_args'"run solr post -url http://localhost:8983/solr/test_args/update -mode args -type application/xml -out -commit "<delete><query>*:*</query></delete>"@@ -165,7 +165,7 @@ capture_echo_to_solr() {@test "stdin mode" {- run solr create_collection -c test_stdin -d _default+ run solr create -c test_stdin -d _defaultassert_output --partial "Created collection 'test_stdin'"run capture_echo_to_solrdiff --git a/solr/packaging/test/test_postlogs.bats b/solr/packaging/test/test_postlogs.batsindex 64c8230fefd..36c5941c80e 100644--- a/solr/packaging/test/test_postlogs.bats+++ b/solr/packaging/test/test_postlogs.bats@@ -39,7 +39,7 @@ teardown() {}@test "post solr log into solr via script" {- run solr create_collection -c COLL_NAME+ run solr create -c COLL_NAMEassert_output --partial "Created collection 'COLL_NAME'"run postlogs http://localhost:8983/solr/COLL_NAME ${SOLR_LOGS_DIR}/solr.log@@ -51,7 +51,7 @@ teardown() {}@test "post solr log into solr via cli" {- run solr create_collection -c COLL_NAME+ run solr create -c COLL_NAMEassert_output --partial "Created collection 'COLL_NAME'"run solr postlogs -url http://localhost:8983/solr/COLL_NAME -rootdir ${SOLR_LOGS_DIR}/solr.logdiff --git a/solr/packaging/test/test_security_manager.bats b/solr/packaging/test/test_security_manager.batsindex 0d7fa163a1a..606d2d33d25 100644--- a/solr/packaging/test/test_security_manager.bats+++ b/solr/packaging/test/test_security_manager.bats@@ -42,7 +42,7 @@ teardown() {export SOLR_SECURITY_MANAGER_ENABLED=trueexport SOLR_OPTS="-Dsolr.allowPaths=${backup_dir} -Djava.io.tmpdir=${test_tmp_dir}"run solr start -c- run solr create_collection -c COLL_NAME+ run solr create -c COLL_NAMErun solr api -get "http://localhost:8983/solr/admin/collections?action=BACKUP&name=test&collection=COLL_NAME&location=file://${backup_dir}"assert_output --partial '"status":0'diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/docker-faq.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/docker-faq.adocindex 694500a0151..2bb81b49465 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/docker-faq.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/docker-faq.adoc@@ -69,7 +69,7 @@ docker run -it --rm -v /home/docker-volumes/mysolr1:/target solr cp -r server/soSOLR_CONTAINER=$(docker run -d -P -v /home/docker-volumes/mysolr1/solr:/opt/solr/server/solr solr)# create a new core-docker exec -it --user=solr $SOLR_CONTAINER solr create_core -c gettingstarted+docker exec -it --user=solr $SOLR_CONTAINER solr create -c gettingstarted# check the volume on the host:ls /home/docker-volumes/mysolr1/solr/@@ -105,7 +105,7 @@ docker create -v /opt/solr/server/solr --name mysolr1data solr /bin/trueSOLR_CONTAINER=$(docker run -d -P --volumes-from=mysolr1data solr)# create a new core-docker exec -it --user=solr $SOLR_CONTAINER solr create_core -c gettingstarted+docker exec -it --user=solr $SOLR_CONTAINER solr create -c gettingstarted# make a change to the config, using the config APIdocker exec -it --user=solr $SOLR_CONTAINER curl http://localhost:8983/solr/gettingstarted/config -H 'Content-type:application/json' -d '{@@ -215,7 +215,7 @@ Create a collection:[source,bash]-----docker exec -i -t solr1 solr create_collection \+docker exec -i -t solr1 solr create \-c gettingstarted -shards 2 -p 8983----diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/docker-networking.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/docker-networking.adocindex 66b1b75446e..463fde67a92 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/docker-networking.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/docker-networking.adoc@@ -197,7 +197,7 @@ Next let's create a collection:[source,bash]-----ssh -n $ZKSOLR1_HOST docker exec -i zksolr1 /opt/solr/bin/solr create_collection -c my_collection1 -shards 2 -p 8983+ssh -n $ZKSOLR1_HOST docker exec -i zksolr1 /opt/solr/bin/solr create -c my_collection1 -shards 2 -p 8983----To load data, and see it was split over shards:diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adocindex b82e642e754..80eaebf4cef 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc@@ -631,7 +631,6 @@ The `bin/solr` script can also help you create new collections or cores, or dele=== Create a Core or CollectionThe `create` command creates a core or collection depending on whether Solr is running in standalone (core) or SolrCloud mode (collection).-In other words, this action detects which mode Solr is running in, and then takes the appropriate action (either `create_core` or `create_collection`).`bin/solr create [options]`@@ -711,178 +710,10 @@ It is possible to override this warning with the -force parameter.+*Example*: `bin/solr create -c foo -force`-=== Create a Collection--The `create_collection` command creates a collection, and is only available when running in SolrCloud mode.--`bin/solr create_collection [options]`--`bin/solr create_collection -help`--==== Create Collection Parameters--`-c <name>`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-Name of the collection to create.-+-*Example*: `bin/solr create_collection -c mycollection`--`-d <confdir>`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `_default`-|===-+-Configuration directory to copy when creating the new collection.-+-See the section <<Configuration Directories and SolrCloud>> below for more details about this option when running in SolrCloud mode. including some built in example configurations.-+-`_default` is also known as xref:indexing-guide:schemaless-mode.adoc[].-+-*Example*: `bin/solr create_collection -d _default`-+-Alternatively, you can pass the path to your own configuration directory instead of using one of the built-in configurations.-+-*Example*: `bin/solr create_collection -c mycoll -d /tmp/myconfig`-+-By default the script will upload the specified confdir directory into Zookeeper using the same name as the collection (-c) option.-Alternatively, if you want to reuse an existing directory or create a confdir in Zookeeper that can be shared by multiple collections, use the -n option-+--`-n <configName>`::-+-[%autowidth,frame=none]-|===-|Optional |Default: _see description_-|===-+-Name the configuration directory in Zookeeper.-By default, the configuration will be uploaded to Zookeeper using the collection name (-c), but if you want to use an existing directory or override the name of the configuration in Zookeeper, then use the -c option.-UMMMM... I COPIED THE ABOVE LINE FROM bin/solr create_collection -h output, but I don't get it. And bin/solr create_collection -n basic -c mycoll works, it create a copy of _default as "basic" configset... UMMM?-+-*Example*: `bin/solr create_collection -n basic -c mycoll`--`-p <port>` or `-port <port>`::-+-[%autowidth,frame=none]-|===-|Optional |Default: _see description_-|===-+-Port of a local Solr instance where you want to create the new collection.-If not specified, the script will search the local system for a running Solr instance and will use the port of the first server it finds.-+-This option is useful if you are running multiple Solr instances on the same host, thus requiring you to be specific about which instance to create the core in.-+-*Example*: `bin/solr create -p 8983`--`-s <shards>` or `-shards <shards>`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `1`-|===-+-Number of shards to split a collection into.-+-*Example*: `bin/solr create_collection -s 2`--`-rf <replicas>` or `-replicationFactor <replicas>`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `1`-|===-+-Number of copies of each document in the collection.-The default is `1` (no replication).-+-*Example*: `bin/solr create_collection -rf 2`--`-force`::-+-[%autowidth,frame=none]-|===-|Optional |Default: none-|===-+-If attempting to run create as "root" user, the script will exit with a warning that running Solr or actions against Solr as "root" can cause problems.-It is possible to override this warning with the -force parameter.-+-*Example*: `bin/solr create_collection -c foo -force`--=== Create a Core--The `create_core` command creates a core and is only available when running in user-managed (single-node) mode.--`bin/solr create_core [options]`--`bin/solr create_core -help`--==== Create Core Parameters--`-c <name>`::-+-[%autowidth,frame=none]-|===-s|Required |Default: none-|===-+-Name of the core to create.-+-*Example*: `bin/solr create -c mycore`--`-d <confdir>`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `_default`-|===-+-The configuration directory to use when creating a new core.-+-*Example*: `bin/solr create -d _default`-+-Alternatively, you can pass the path to your own configuration directory instead of using one of the built-in configurations.-+-*Example*: `bin/solr create_collection -c mycore -d /tmp/myconfig`--`-p <port>` or `-port <port>`::-+-[%autowidth,frame=none]-|===-|Optional |Default: _see description_-|===-+-The port of a local Solr instance to create the new core.-By default the script tries to detect the port by looking for running Solr instances.-+-This option is useful if you are running multiple Solr instances on the same host, thus requiring you to be specific about which instance to create the core in.-+-*Example*: `bin/solr create -p 8983`--`-force`::-+-[%autowidth,frame=none]-|===-|Optional |Default: none-|===-+-If attempting to run create as "root" user, the script will exit with a warning that running Solr or actions against Solr as "root" can cause problems.-It is possible to override this warning with the -force parameter.-+-*Example*: `bin/solr create -c foo -force`-==== Configuration Directories and SolrCloudBefore creating a collection in SolrCloud, the configuration directory used by the collection must be uploaded to ZooKeeper.-The `create` and `create_collection` commands supports several use cases for how collections and configuration directories work.+The `create` command supports several use cases for how collections and configuration directories work.The main decision you need to make is whether a configuration directory in ZooKeeper should be shared across multiple collections.Let's work through a few examples to illustrate how configuration directories work in SolrCloud.@@ -1788,7 +1619,7 @@ Create a new collection to import the exported documents into:[,console]-----$ bin/solr create_collection -c test_collection -n techproducts+$ bin/solr create -c test_collection -n techproducts----Now import the data with either of these methods:diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-in-docker.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-in-docker.adocindex 491b2ba248c..b43562951bf 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-in-docker.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-in-docker.adoc@@ -125,7 +125,7 @@ The first is exactly the same: start Solr running in a container, then execute t[source,bash]----docker run -d -p 8983:8983 --name my_solr solr-docker exec -it my_solr solr create_core -c gettingstarted+docker exec -it my_solr solr create -c gettingstarted----This is not very convenient for users, and makes it harder to turn it into configuration for Docker Compose and orchestration tools like Kubernetes.@@ -189,7 +189,7 @@ The third way is to use a separate container:[source,bash]-----docker run -e SOLR_HOST=solr1 --network docs_solr solr solr create_collection -c gettingstarted3 -p 8983+docker run -e SOLR_HOST=solr1 --network docs_solr solr solr create -c gettingstarted3 -p 8983----The fourth way is to use the remote API, from the host or from one of the containers, or some new container on the same network (adjust the hostname accordingly):@@ -224,7 +224,7 @@ The same works if you use the <<docker-compose,example docker compose cluster>>,[source,bash]-----docker run -e SOLR_HOST=solr1 --network=mycluster_solr solr solr create_collection -c books -p 8983+docker run -e SOLR_HOST=solr1 --network=mycluster_solr solr solr create -c books -p 8983docker run --rm -v "$PWD/mydata:/mydata" --network=mycluster_solr solr post -c books /mydata/books.csv -host solr1----