From 04ca619a4fda21d5b628e1844184027c3a7d39a2 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 11 Feb 2026 09:56:19 -0500 Subject: [PATCH 01/13] Add in --prompts capablity. Its so lovely! --- solr/bin/solr | 8 + .../org/apache/solr/cli/RunExampleTool.java | 57 ++++++- .../solr/cli/TestSolrCLIRunExample.java | 150 ++++++++++++++++++ 3 files changed, 211 insertions(+), 4 deletions(-) diff --git a/solr/bin/solr b/solr/bin/solr index ec7f596144db..f78fcc779918 100755 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -817,6 +817,14 @@ if [ $# -gt 0 ]; then PASS_TO_RUN_EXAMPLE+=("--no-prompt") shift ;; + --prompts) + if [[ -z "$2" || "${2:0:1}" == "-" ]]; then + print_usage "$SCRIPT_CMD" "Prompt values are required when using the $1 option!" + exit 1 + fi + PASS_TO_RUN_EXAMPLE+=("--prompts" "$2") + shift 2 + ;; --verbose) verbose=true SOLR_LOG_LEVEL=DEBUG diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java index 9fcd71c911d0..0d44e6b100b7 100644 --- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java +++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java @@ -73,6 +73,16 @@ public class RunExampleTool extends ToolBase { "Don't prompt for input; accept all defaults when running examples that accept user input.") .build(); + private static final Option PROMPTS_OPTION = + Option.builder() + .longOpt("prompts") + .hasArg() + .argName("VALUES") + .desc( + "Provide comma-separated values for prompts. Same as --no-prompt but uses provided values instead of defaults. " + + "Example: --prompts 3,8983,8984,8985,\"gettingstarted\",2,2,_default") + .build(); + private static final Option EXAMPLE_OPTION = Option.builder("e") .longOpt("example") @@ -176,6 +186,7 @@ public class RunExampleTool extends ToolBase { protected Path exampleDir; protected Path solrHomeDir; protected String urlScheme; + private boolean usingPrompts = false; /** Default constructor used by the framework when running as a command-line application. */ public RunExampleTool(ToolRuntime runtime) { @@ -197,6 +208,7 @@ public String getName() { public Options getOptions() { return super.getOptions() .addOption(NO_PROMPT_OPTION) + .addOption(PROMPTS_OPTION) .addOption(EXAMPLE_OPTION) .addOption(SCRIPT_OPTION) .addOption(SERVER_DIR_OPTION) @@ -214,6 +226,13 @@ public Options getOptions() { @Override public void runImpl(CommandLine cli) throws Exception { + // Validate that --no-prompt and --prompts are not used together + if (cli.hasOption(NO_PROMPT_OPTION) && cli.hasOption(PROMPTS_OPTION)) { + throw new IllegalArgumentException( + "Cannot use both --no-prompt and --prompts options together. " + + "Use --no-prompt to accept defaults, or --prompts to provide specific values."); + } + this.urlScheme = cli.getOptionValue(URL_SCHEME_OPTION, "http"); String exampleType = cli.getOptionValue(EXAMPLE_OPTION); @@ -515,6 +534,7 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception protected void runCloudExample(CommandLine cli) throws Exception { + usingPrompts = cli.hasOption(PROMPTS_OPTION); boolean prompt = !cli.hasOption(NO_PROMPT_OPTION); int numNodes = 2; int[] cloudPorts = new int[] {8983, 7574, 8984, 7575}; @@ -530,10 +550,24 @@ protected void runCloudExample(CommandLine cli) throws Exception { echo("\nWelcome to the SolrCloud example!\n"); - Scanner readInput = prompt ? new Scanner(userInput, StandardCharsets.UTF_8) : null; + Scanner readInput = null; + if (usingPrompts) { + // Create a scanner from the provided prompts + String promptsValue = cli.getOptionValue(PROMPTS_OPTION); + InputStream promptsStream = + new java.io.ByteArrayInputStream(promptsValue.getBytes(StandardCharsets.UTF_8)); + readInput = new Scanner(promptsStream, StandardCharsets.UTF_8); + readInput.useDelimiter(","); + prompt = true; // Enable prompting code path, but reading from prompts instead of user + } else if (prompt) { + readInput = new Scanner(userInput, StandardCharsets.UTF_8); + } + if (prompt) { - echo( - "This interactive session will help you launch a SolrCloud cluster on your local workstation."); + if (!usingPrompts) { + echo( + "This interactive session will help you launch a SolrCloud cluster on your local workstation."); + } // get the number of nodes to start numNodes = @@ -1121,9 +1155,24 @@ protected String prompt(Scanner s, String prompt) { protected String prompt(Scanner s, String prompt, String defaultValue) { echo(prompt); - String nextInput = s.nextLine(); + String nextInput; + if (usingPrompts) { + // Reading from prompts option - use next() instead of nextLine() + nextInput = s.hasNext() ? s.next() : null; + // Echo the value being used from prompts + if (nextInput != null) { + echo(nextInput); + } + } else { + // Reading from user input - use nextLine() + nextInput = s.nextLine(); + } if (nextInput != null) { nextInput = nextInput.trim(); + // Remove quotes if present (for values like "gettingstarted") + if (nextInput.startsWith("\"") && nextInput.endsWith("\"")) { + nextInput = nextInput.substring(1, nextInput.length() - 1); + } if (nextInput.isEmpty()) nextInput = null; } return (nextInput != null) ? nextInput : defaultValue; diff --git a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java index db26383eb7f7..7b21610d381d 100644 --- a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java +++ b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java @@ -525,6 +525,156 @@ public void testInteractiveSolrCloudExample() throws Exception { executor.execute(org.apache.commons.exec.CommandLine.parse("bin/solr stop -p " + bindPort)); } + /** + * Test the --prompts option that allows providing all prompt values as a comma-separated string + * without requiring interactive input. + */ + @Test + public void testSolrCloudExampleWithPrompts() throws Exception { + Path solrHomeDir = ExternalPaths.SERVER_HOME; + if (!Files.isDirectory(solrHomeDir)) + fail(solrHomeDir + " not found and is required to run this test!"); + + Path solrExampleDir = createTempDir(); + Path solrServerDir = solrHomeDir.getParent(); + + int bindPort = -1; + try (ServerSocket socket = new ServerSocket(0)) { + bindPort = socket.getLocalPort(); + } + + String collectionName = "testCloudExampleWithPrompts"; + + // Provide all prompt values via --prompts option: + // numNodes, port1, collectionName, numShards, replicationFactor, configName + String promptsValue = "1," + bindPort + ",\"" + collectionName + "\",2,2,_default"; + + String[] toolArgs = + new String[] { + "--example", + "cloud", + "--server-dir", + solrServerDir.toString(), + "--example-dir", + solrExampleDir.toString(), + "--prompts", + promptsValue + }; + + // capture tool output to stdout + CLITestHelper.TestingRuntime runtime = new CLITestHelper.TestingRuntime(true); + + RunExampleExecutor executor = new RunExampleExecutor(); + closeables.add(executor); + + RunExampleTool tool = new RunExampleTool(executor, System.in, runtime); + try { + tool.runTool(SolrCLI.processCommandLineArgs(tool, toolArgs)); + } catch (Exception e) { + System.err.println( + "RunExampleTool failed due to: " + + e + + "; stdout from tool prior to failure: " + + runtime.getOutput()); + throw e; + } + + String toolOutput = runtime.getOutput(); + + // verify Solr is running on the expected port and verify the collection exists + String solrUrl = "http://localhost:" + bindPort + "/solr"; + if (!CLIUtils.safeCheckCollectionExists(solrUrl, collectionName, null)) { + fail( + "After running Solr cloud example with --prompts, test collection '" + + collectionName + + "' not found in Solr at: " + + solrUrl + + "; tool output: " + + toolOutput); + } + + // verify the collection was created with the specified parameters + try (CloudSolrClient cloudClient = + new RandomizingCloudSolrClientBuilder( + Collections.singletonList(executor.solrCloudCluster.getZkServer().getZkAddress()), + Optional.empty()) + .withDefaultCollection(collectionName) + .build()) { + + // index some test docs to verify the collection works + int numDocs = 5; + for (int d = 0; d < numDocs; d++) { + SolrInputDocument doc = new SolrInputDocument(); + doc.setField("id", "doc" + d); + doc.setField("test_s", "prompts"); + cloudClient.add(doc); + } + cloudClient.commit(); + + QueryResponse qr = cloudClient.query(new SolrQuery("test_s:prompts")); + assertEquals( + "Expected " + + numDocs + + " docs in the " + + collectionName + + " collection created via --prompts", + numDocs, + qr.getResults().getNumFound()); + } + + // Verify output contains the prompts values + assertTrue( + "Tool output should contain the collection name", toolOutput.contains(collectionName)); + + // delete the collection + DeleteTool deleteTool = new DeleteTool(runtime); + String[] deleteArgs = new String[] {"--name", collectionName, "--solr-url", solrUrl}; + deleteTool.runTool(SolrCLI.processCommandLineArgs(deleteTool, deleteArgs)); + + // stop the test instance + executor.execute(org.apache.commons.exec.CommandLine.parse("bin/solr stop -p " + bindPort)); + } + + /** Test that using both --no-prompt and --prompts options together throws an error. */ + @Test + public void testPromptsAndNoPromptConflict() throws Exception { + Path solrHomeDir = ExternalPaths.SERVER_HOME; + if (!Files.isDirectory(solrHomeDir)) + fail(solrHomeDir + " not found and is required to run this test!"); + + Path solrExampleDir = createTempDir(); + Path solrServerDir = solrHomeDir.getParent(); + + String[] toolArgs = + new String[] { + "--example", + "cloud", + "--server-dir", + solrServerDir.toString(), + "--example-dir", + solrExampleDir.toString(), + "--no-prompt", + "--prompts", + "1,8983,\"test\",2,2,_default" + }; + + CLITestHelper.TestingRuntime runtime = new CLITestHelper.TestingRuntime(true); + RunExampleExecutor executor = new RunExampleExecutor(); + closeables.add(executor); + + RunExampleTool tool = new RunExampleTool(executor, System.in, runtime); + + int exitCode = 100; // Initialize to unexpected value + try { + exitCode = tool.runTool(SolrCLI.processCommandLineArgs(tool, toolArgs)); + } catch (Exception e) { + fail("Should not throw exception, but return error code. Got: " + e); + } + + assertEquals( + "Expected error code 1 when using both --no-prompt and --prompts together", 1, exitCode); + } + @Test public void testFailExecuteScript() throws Exception { Path solrHomeDir = ExternalPaths.SERVER_HOME; From 0e8715724e775f1a0646f01a8f8d3a46e9db2278 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 11 Feb 2026 10:14:47 -0500 Subject: [PATCH 02/13] support in bin/solr scirpts, reorg the param details --- solr/bin/solr | 16 +++++++++------- solr/bin/solr.cmd | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/solr/bin/solr b/solr/bin/solr index f78fcc779918..c72a9205229a 100755 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -407,12 +407,6 @@ function print_usage() { echo " --data-home Sets the solr.data.home system property, where Solr will store index data in /data subdirectories." echo " If not set, Solr uses solr.solr.home for config and data." echo "" - echo " -e/--example Name of the example to run; available examples:" - echo " cloud: SolrCloud example" - echo " techproducts: Comprehensive example illustrating many of Solr's core capabilities" - echo " schemaless: Schema-less example (schema is inferred from data during indexing)" - echo " films: Example of starting with _default configset and adding explicit fields dynamically" - echo "" echo " --jvm-opts Additional parameters to pass to the JVM when starting Solr, such as to setup" echo " Java debug options. For example, to enable a Java debugger to attach to the Solr JVM" echo " you could pass: --jvm-opts \"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983\"" @@ -423,7 +417,15 @@ function print_usage() { echo " you could pass: -j \"--include-jetty-dir=/etc/jetty/custom/server/\"" echo " In most cases, you should wrap the additional parameters in double quotes." echo "" - echo " -y/--no-prompt Don't prompt for input; accept all defaults when running examples that accept user input" + echo " -e/--example Name of the example to run; available examples:" + echo " cloud: SolrCloud example" + echo " techproducts: Comprehensive example illustrating many of Solr's core capabilities" + echo " schemaless: Schema-less example (schema is inferred from data during indexing)" + echo " films: Example of starting with _default configset and adding explicit fields dynamically" + echo "" + echo " -y/--no-prompt Don't prompt for input; accept all defaults when running examples that accept user input." + echo "" + echo " --prompt Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." echo "" echo " --force If attempting to start Solr as the root user, the script will exit with a warning that running Solr as \"root\" can cause problems." echo " It is possible to override this warning with the '--force' parameter." diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index 52be92ed3de3..5db2b235f885 100755 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -325,12 +325,6 @@ goto err @echo --data-home dir Sets the solr.data.home system property, where Solr will store index data in ^/data subdirectories. @echo If not set, Solr uses solr.solr.home for both config and data. @echo. -@echo -e/--example name Name of the example to run; available examples: -@echo cloud: SolrCloud example -@echo techproducts: Comprehensive example illustrating many of Solr's core capabilities -@echo schemaless: Schema-less example (schema is inferred from data during indexing) -@echo films: Example of starting with _default configset and defining explicit fields dynamically -@echo. @echo --jvm-opts opts Additional parameters to pass to the JVM when starting Solr, such as to setup @echo Java debug options. For example, to enable a Java debugger to attach to the Solr JVM @echo you could pass: --jvm-opts "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983" @@ -341,8 +335,16 @@ goto err @echo you could pass: -j "--include-jetty-dir=/etc/jetty/custom/server/" @echo In most cases, you should wrap the additional parameters in double quotes. @echo. +@echo -e/--example name Name of the example to run; available examples: +@echo cloud: SolrCloud example +@echo techproducts: Comprehensive example illustrating many of Solr's core capabilities +@echo schemaless: Schema-less example (schema is inferred from data during indexing) +@echo films: Example of starting with _default configset and defining explicit fields dynamically +@echo. @echo -y/--no-prompt Don't prompt for input; accept all defaults when running examples that accept user input @echo. +@echo --prompt Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." +@echo. @echo --verbose and -q/--quiet Verbose or quiet logging. Sets default log level to DEBUG or WARN instead of INFO @echo. goto done @@ -399,6 +401,7 @@ IF "%1"=="-j" goto set_addl_jetty_config IF "%1"=="--jettyconfig" goto set_addl_jetty_config IF "%1"=="-y" goto set_noprompt IF "%1"=="--no-prompt" goto set_noprompt +IF "%1"=="--prompt" goto set_prompt REM Skip stop arg parsing if not stop command IF NOT "%SCRIPT_CMD%"=="stop" goto parse_general_args @@ -695,6 +698,12 @@ set "PASS_TO_RUN_EXAMPLE=--no-prompt !PASS_TO_RUN_EXAMPLE!" SHIFT goto parse_args +:set_prompt +set "PASS_TO_RUN_EXAMPLE=--prompt %~2 !PASS_TO_RUN_EXAMPLE!" + +SHIFT +goto parse_args + REM Handle invalid arguments passed to special commands (start, stop, restart) :invalid_cmd_line @echo. From 2a7b1e4b53cd9eafd329d53eb41d67444d40cb01 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 11 Feb 2026 10:37:30 -0500 Subject: [PATCH 03/13] rework docs --- solr/bin/solr | 2 +- solr/bin/solr.cmd | 2 +- .../pages/solr-control-script-reference.adoc | 83 +++++++++++-------- 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/solr/bin/solr b/solr/bin/solr index c72a9205229a..55dff59409e8 100755 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -425,7 +425,7 @@ function print_usage() { echo "" echo " -y/--no-prompt Don't prompt for input; accept all defaults when running examples that accept user input." echo "" - echo " --prompt Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." + echo " --prompts Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." echo "" echo " --force If attempting to start Solr as the root user, the script will exit with a warning that running Solr as \"root\" can cause problems." echo " It is possible to override this warning with the '--force' parameter." diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index 5db2b235f885..b7638a48ba29 100755 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -699,7 +699,7 @@ SHIFT goto parse_args :set_prompt -set "PASS_TO_RUN_EXAMPLE=--prompt %~2 !PASS_TO_RUN_EXAMPLE!" +set "PASS_TO_RUN_EXAMPLE=--prompts %~2 !PASS_TO_RUN_EXAMPLE!" SHIFT goto parse_args 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.adoc index 577c566eb4a2..c62ec8d4d0de 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 @@ -106,27 +106,6 @@ When running multiple instances of Solr on the same host, it is more common to u + *Example*: `bin/solr start --server-dir newServerDir` -`-e `:: -+ -[%autowidth,frame=none] -|=== -|Optional |Default: none -|=== -+ -Start Solr with an example configuration. -These examples are provided to help you get started faster with Solr generally, or just try a specific feature. -+ -The available options are: - -* `cloud`: SolrCloud example -* `techproducts`: Comprehensive example illustrating many of Solr's core capabilities -* `schemaless`: Schema-less example (schema is inferred from data during indexing) -* `films`: Example of starting with _default configset and adding explicit fields dynamically -+ -See the section <> below for more details on the example configurations. -+ -*Example*: `bin/solr start -e schemaless` - `-f`:: + [%autowidth,frame=none] @@ -162,20 +141,6 @@ Sets the min (`-Xms`) and max (`-Xmx`) heap size for the JVM running Solr. + *Example*: `bin/solr start -m 4g` results in `-Xms4g -Xmx4g` settings. -`--no-prompt`:: -+ -[%autowidth,frame=none] -|=== -|Optional |Default: none -|=== -+ -Don't prompt for input; accept all defaults when running examples that accept user input. -+ -For example, when using the "cloud" example, an interactive session guides you through several options for your SolrCloud cluster. -If you want to accept all of the defaults, you can simply add the `--no-prompt` option to your request. -+ -*Example*: `bin/solr start -e cloud --no-prompt` - `-p `:: + [%autowidth,frame=none] @@ -277,6 +242,54 @@ To emphasize how the default settings work take a moment to understand that the `bin/solr start --host localhost -p 8983 --server-dir server --solr-home solr -m 512m` +`-e ` or `--example `:: ++ +[%autowidth,frame=none] +|=== +|Optional |Default: none +|=== ++ +Start Solr with an example configuration. +These examples are provided to help you get started faster with Solr generally, or just try a specific feature. ++ +The available options are: + +* `cloud`: SolrCloud example +* `techproducts`: Comprehensive example illustrating many of Solr's core capabilities +* `schemaless`: Schema-less example (schema is inferred from data during indexing) +* `films`: Example of starting with _default configset and adding explicit fields dynamically ++ +See the section <> below for more details on the example configurations. ++ +*Example*: `bin/solr start -e schemaless` + +`--no-prompt`:: ++ +[%autowidth,frame=none] +|=== +|Optional |Default: none +|=== ++ +Don't prompt for input; accept all defaults when running examples that accept user input. ++ +For example, when using the "cloud" example, an interactive session guides you through several options for your SolrCloud cluster. +If you want to accept all of the defaults, you can simply add the `--no-prompt` option to your request. ++ +*Example*: `bin/solr start -e cloud --no-prompt` + +`--prompts `:: ++ +[%autowidth,frame=none] +|=== +|Optional |Default: none +|=== ++ +Don't prompt for input; provide defaults in comma delimited format when running examples that accept user input. ++ +For example, when using the "cloud" example, can start a three node cluster on specific ports: ++ +*Example*: `bin/solr start -e cloud --prompts=3,9000,9001,9002,"mycollection",2,2,_defaults` + It is not necessary to define all of the options when starting if the defaults are fine for your needs. ==== Setting Java System Properties From f5a2c4e10c3fb3cb0fe44dca330c11620b9c81b6 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 11 Feb 2026 10:40:14 -0500 Subject: [PATCH 04/13] doc the change --- changelog/unreleased/SOLR-18118.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 changelog/unreleased/SOLR-18118.yml diff --git a/changelog/unreleased/SOLR-18118.yml b/changelog/unreleased/SOLR-18118.yml new file mode 100644 index 000000000000..0e86ac2a669d --- /dev/null +++ b/changelog/unreleased/SOLR-18118.yml @@ -0,0 +1,8 @@ +# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc +title: Script creating a cluster using bin/solr start -e cloud with --prompts option. +type: added # added, changed, fixed, deprecated, removed, dependency_update, security, other +authors: + - name: Eric Pugh +links: + - name: SOLR-18118 + url: https://issues.apache.org/jira/browse/SOLR-18118 From b4e433263835cf7eba839da8c0e6a47e0879c54d Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 11 Feb 2026 13:32:41 -0500 Subject: [PATCH 05/13] Fix up some commands in the docs. --- .../deployment-guide/pages/solr-control-script-reference.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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.adoc index c62ec8d4d0de..33277d82c3a7 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 @@ -689,7 +689,7 @@ This defaults to the same name as the collection or core. + *Example*: `bin/solr create -n basic` -`-sh ` or `-shards `:: +`-sh ` or `--shards `:: + [%autowidth,frame=none] |=== @@ -950,7 +950,7 @@ Either `--credentials` or `--prompt` *must* be specified. When `true`, this blocks out access to unauthenticated users from accessing Solr. When `false`, unauthenticated users will still be able to access Solr, but only for operations not explicitly requiring a user role in the Authorization plugin configuration. -`--solrIncludeFile `:: +`--solr-include-file `:: + [%autowidth,frame=none] |=== From 3a05407b6c6271ab0b8b7d99a6c5fc9bf0f993bd Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 11 Feb 2026 15:50:22 -0500 Subject: [PATCH 06/13] windows fixes! --- solr/bin/solr.cmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index b7638a48ba29..63d4081c8286 100755 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -343,7 +343,7 @@ goto err @echo. @echo -y/--no-prompt Don't prompt for input; accept all defaults when running examples that accept user input @echo. -@echo --prompt Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." +@echo --prompts values Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." @echo. @echo --verbose and -q/--quiet Verbose or quiet logging. Sets default log level to DEBUG or WARN instead of INFO @echo. @@ -401,7 +401,7 @@ IF "%1"=="-j" goto set_addl_jetty_config IF "%1"=="--jettyconfig" goto set_addl_jetty_config IF "%1"=="-y" goto set_noprompt IF "%1"=="--no-prompt" goto set_noprompt -IF "%1"=="--prompt" goto set_prompt +IF "%1"=="--prompt"s goto set_prompts REM Skip stop arg parsing if not stop command IF NOT "%SCRIPT_CMD%"=="stop" goto parse_general_args @@ -698,7 +698,7 @@ set "PASS_TO_RUN_EXAMPLE=--no-prompt !PASS_TO_RUN_EXAMPLE!" SHIFT goto parse_args -:set_prompt +:set_prompts set "PASS_TO_RUN_EXAMPLE=--prompts %~2 !PASS_TO_RUN_EXAMPLE!" SHIFT From e3f6106af32bae8e789b5b33d9d0962f8bbdc733 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 11 Feb 2026 15:52:31 -0500 Subject: [PATCH 07/13] more fixes --- solr/bin/solr.cmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index 63d4081c8286..95fadab4287a 100755 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -343,7 +343,7 @@ goto err @echo. @echo -y/--no-prompt Don't prompt for input; accept all defaults when running examples that accept user input @echo. -@echo --prompts values Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." +@echo --prompts "values" Don't prompt for input; comma delimited list of inputs read when running examples that accept user input. @echo. @echo --verbose and -q/--quiet Verbose or quiet logging. Sets default log level to DEBUG or WARN instead of INFO @echo. @@ -701,6 +701,7 @@ goto parse_args :set_prompts set "PASS_TO_RUN_EXAMPLE=--prompts %~2 !PASS_TO_RUN_EXAMPLE!" +SHIFT SHIFT goto parse_args From 66b631e2169057d020c21197e523bddc4ead5930 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 11 Feb 2026 15:56:15 -0500 Subject: [PATCH 08/13] mention Windows tip --- .../deployment-guide/pages/solr-control-script-reference.adoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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.adoc index 33277d82c3a7..104d903eec35 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 @@ -288,7 +288,9 @@ Don't prompt for input; provide defaults in comma delimited format when running + For example, when using the "cloud" example, can start a three node cluster on specific ports: + -*Example*: `bin/solr start -e cloud --prompts=3,9000,9001,9002,"mycollection",2,2,_defaults` +*Example*: `bin/solr start -e cloud --prompts 3,9000,9001,9002,"mycollection",2,2,_defaults` + +On Windows please wrap the prompts value in double quotes to preserve the comma delimited format. It is not necessary to define all of the options when starting if the defaults are fine for your needs. From 077f4f7f8ed39fb1834ada02c6dd8c1efdb544d7 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Tue, 17 Feb 2026 06:06:54 -0500 Subject: [PATCH 09/13] Adopt --prompt-inputs name --- changelog/unreleased/SOLR-18118.yml | 3 +- solr/bin/solr | 6 +-- solr/bin/solr.cmd | 8 ++-- .../org/apache/solr/cli/RunExampleTool.java | 27 +++++------ .../solr/cli/TestSolrCLIRunExample.java | 48 ++----------------- 5 files changed, 26 insertions(+), 66 deletions(-) diff --git a/changelog/unreleased/SOLR-18118.yml b/changelog/unreleased/SOLR-18118.yml index 0e86ac2a669d..e3d703091ff7 100644 --- a/changelog/unreleased/SOLR-18118.yml +++ b/changelog/unreleased/SOLR-18118.yml @@ -1,8 +1,9 @@ # See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc -title: Script creating a cluster using bin/solr start -e cloud with --prompts option. +title: Script creating a cluster using bin/solr start -e cloud with --prompt-inputs option. type: added # added, changed, fixed, deprecated, removed, dependency_update, security, other authors: - name: Eric Pugh + - name: Rahul Goswami links: - name: SOLR-18118 url: https://issues.apache.org/jira/browse/SOLR-18118 diff --git a/solr/bin/solr b/solr/bin/solr index 55dff59409e8..eaa417ca90d0 100755 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -425,7 +425,7 @@ function print_usage() { echo "" echo " -y/--no-prompt Don't prompt for input; accept all defaults when running examples that accept user input." echo "" - echo " --prompts Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." + echo " --prompt-inputs Don't prompt for input; comma delimited list of inputs read when running examples that accept user input." echo "" echo " --force If attempting to start Solr as the root user, the script will exit with a warning that running Solr as \"root\" can cause problems." echo " It is possible to override this warning with the '--force' parameter." @@ -819,12 +819,12 @@ if [ $# -gt 0 ]; then PASS_TO_RUN_EXAMPLE+=("--no-prompt") shift ;; - --prompts) + --prompt-inputs) if [[ -z "$2" || "${2:0:1}" == "-" ]]; then print_usage "$SCRIPT_CMD" "Prompt values are required when using the $1 option!" exit 1 fi - PASS_TO_RUN_EXAMPLE+=("--prompts" "$2") + PASS_TO_RUN_EXAMPLE+=("--prompt-inputs" "$2") shift 2 ;; --verbose) diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index 95fadab4287a..e30cc4416fa8 100755 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -343,7 +343,7 @@ goto err @echo. @echo -y/--no-prompt Don't prompt for input; accept all defaults when running examples that accept user input @echo. -@echo --prompts "values" Don't prompt for input; comma delimited list of inputs read when running examples that accept user input. +@echo --prompt-inputs values Don't prompt for input; comma delimited list of inputs read when running examples that accept user input. @echo. @echo --verbose and -q/--quiet Verbose or quiet logging. Sets default log level to DEBUG or WARN instead of INFO @echo. @@ -401,7 +401,7 @@ IF "%1"=="-j" goto set_addl_jetty_config IF "%1"=="--jettyconfig" goto set_addl_jetty_config IF "%1"=="-y" goto set_noprompt IF "%1"=="--no-prompt" goto set_noprompt -IF "%1"=="--prompt"s goto set_prompts +IF "%1"=="--prompt-inputs" goto set_prompt_inputs REM Skip stop arg parsing if not stop command IF NOT "%SCRIPT_CMD%"=="stop" goto parse_general_args @@ -698,8 +698,8 @@ set "PASS_TO_RUN_EXAMPLE=--no-prompt !PASS_TO_RUN_EXAMPLE!" SHIFT goto parse_args -:set_prompts -set "PASS_TO_RUN_EXAMPLE=--prompts %~2 !PASS_TO_RUN_EXAMPLE!" +:set_prompt_inputs +set "PASS_TO_RUN_EXAMPLE=--prompt-inputs %~2 !PASS_TO_RUN_EXAMPLE!" SHIFT SHIFT diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java index 0d44e6b100b7..b5b21f6450fd 100644 --- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java +++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java @@ -73,14 +73,14 @@ public class RunExampleTool extends ToolBase { "Don't prompt for input; accept all defaults when running examples that accept user input.") .build(); - private static final Option PROMPTS_OPTION = + private static final Option PROMPT_INPUTS_OPTION = Option.builder() - .longOpt("prompts") + .longOpt("prompt-inputs") .hasArg() .argName("VALUES") .desc( "Provide comma-separated values for prompts. Same as --no-prompt but uses provided values instead of defaults. " - + "Example: --prompts 3,8983,8984,8985,\"gettingstarted\",2,2,_default") + + "Example: --prompt-inputs 3,8983,8984,8985,\"gettingstarted\",2,2,_default") .build(); private static final Option EXAMPLE_OPTION = @@ -186,7 +186,7 @@ public class RunExampleTool extends ToolBase { protected Path exampleDir; protected Path solrHomeDir; protected String urlScheme; - private boolean usingPrompts = false; + private boolean usingPromptInputs = false; /** Default constructor used by the framework when running as a command-line application. */ public RunExampleTool(ToolRuntime runtime) { @@ -208,7 +208,7 @@ public String getName() { public Options getOptions() { return super.getOptions() .addOption(NO_PROMPT_OPTION) - .addOption(PROMPTS_OPTION) + .addOption(PROMPT_INPUTS_OPTION) .addOption(EXAMPLE_OPTION) .addOption(SCRIPT_OPTION) .addOption(SERVER_DIR_OPTION) @@ -226,11 +226,10 @@ public Options getOptions() { @Override public void runImpl(CommandLine cli) throws Exception { - // Validate that --no-prompt and --prompts are not used together - if (cli.hasOption(NO_PROMPT_OPTION) && cli.hasOption(PROMPTS_OPTION)) { + if (cli.hasOption(NO_PROMPT_OPTION) && cli.hasOption(PROMPT_INPUTS_OPTION)) { throw new IllegalArgumentException( - "Cannot use both --no-prompt and --prompts options together. " - + "Use --no-prompt to accept defaults, or --prompts to provide specific values."); + "Cannot use both --no-prompt and --prompt-inputs options together. " + + "Use --no-prompt to accept defaults, or --prompt-inputs to provide specific values."); } this.urlScheme = cli.getOptionValue(URL_SCHEME_OPTION, "http"); @@ -534,7 +533,7 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception protected void runCloudExample(CommandLine cli) throws Exception { - usingPrompts = cli.hasOption(PROMPTS_OPTION); + usingPromptInputs = cli.hasOption(PROMPT_INPUTS_OPTION); boolean prompt = !cli.hasOption(NO_PROMPT_OPTION); int numNodes = 2; int[] cloudPorts = new int[] {8983, 7574, 8984, 7575}; @@ -551,9 +550,9 @@ protected void runCloudExample(CommandLine cli) throws Exception { echo("\nWelcome to the SolrCloud example!\n"); Scanner readInput = null; - if (usingPrompts) { + if (usingPromptInputs) { // Create a scanner from the provided prompts - String promptsValue = cli.getOptionValue(PROMPTS_OPTION); + String promptsValue = cli.getOptionValue(PROMPT_INPUTS_OPTION); InputStream promptsStream = new java.io.ByteArrayInputStream(promptsValue.getBytes(StandardCharsets.UTF_8)); readInput = new Scanner(promptsStream, StandardCharsets.UTF_8); @@ -564,7 +563,7 @@ protected void runCloudExample(CommandLine cli) throws Exception { } if (prompt) { - if (!usingPrompts) { + if (!usingPromptInputs) { echo( "This interactive session will help you launch a SolrCloud cluster on your local workstation."); } @@ -1156,7 +1155,7 @@ protected String prompt(Scanner s, String prompt) { protected String prompt(Scanner s, String prompt, String defaultValue) { echo(prompt); String nextInput; - if (usingPrompts) { + if (usingPromptInputs) { // Reading from prompts option - use next() instead of nextLine() nextInput = s.hasNext() ? s.next() : null; // Echo the value being used from prompts diff --git a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java index 7b21610d381d..e4c5d5187cb3 100644 --- a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java +++ b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java @@ -526,8 +526,8 @@ public void testInteractiveSolrCloudExample() throws Exception { } /** - * Test the --prompts option that allows providing all prompt values as a comma-separated string - * without requiring interactive input. + * Test the --prompt-inputs option that allows providing all prompt values as a comma-separated + * string without requiring interactive input. */ @Test public void testSolrCloudExampleWithPrompts() throws Exception { @@ -545,7 +545,7 @@ public void testSolrCloudExampleWithPrompts() throws Exception { String collectionName = "testCloudExampleWithPrompts"; - // Provide all prompt values via --prompts option: + // Provide all prompt values via --prompt-inputs option: // numNodes, port1, collectionName, numShards, replicationFactor, configName String promptsValue = "1," + bindPort + ",\"" + collectionName + "\",2,2,_default"; @@ -557,7 +557,7 @@ public void testSolrCloudExampleWithPrompts() throws Exception { solrServerDir.toString(), "--example-dir", solrExampleDir.toString(), - "--prompts", + "--prompt-inputs", promptsValue }; @@ -635,46 +635,6 @@ public void testSolrCloudExampleWithPrompts() throws Exception { executor.execute(org.apache.commons.exec.CommandLine.parse("bin/solr stop -p " + bindPort)); } - /** Test that using both --no-prompt and --prompts options together throws an error. */ - @Test - public void testPromptsAndNoPromptConflict() throws Exception { - Path solrHomeDir = ExternalPaths.SERVER_HOME; - if (!Files.isDirectory(solrHomeDir)) - fail(solrHomeDir + " not found and is required to run this test!"); - - Path solrExampleDir = createTempDir(); - Path solrServerDir = solrHomeDir.getParent(); - - String[] toolArgs = - new String[] { - "--example", - "cloud", - "--server-dir", - solrServerDir.toString(), - "--example-dir", - solrExampleDir.toString(), - "--no-prompt", - "--prompts", - "1,8983,\"test\",2,2,_default" - }; - - CLITestHelper.TestingRuntime runtime = new CLITestHelper.TestingRuntime(true); - RunExampleExecutor executor = new RunExampleExecutor(); - closeables.add(executor); - - RunExampleTool tool = new RunExampleTool(executor, System.in, runtime); - - int exitCode = 100; // Initialize to unexpected value - try { - exitCode = tool.runTool(SolrCLI.processCommandLineArgs(tool, toolArgs)); - } catch (Exception e) { - fail("Should not throw exception, but return error code. Got: " + e); - } - - assertEquals( - "Expected error code 1 when using both --no-prompt and --prompts together", 1, exitCode); - } - @Test public void testFailExecuteScript() throws Exception { Path solrHomeDir = ExternalPaths.SERVER_HOME; From 6a34214e72586e90cfdd624085837f3e92560398 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Tue, 17 Feb 2026 06:09:38 -0500 Subject: [PATCH 10/13] Update parameter name --- .../pages/solr-control-script-reference.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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.adoc index 104d903eec35..9074bfc3f6ba 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 @@ -277,7 +277,7 @@ If you want to accept all of the defaults, you can simply add the `--no-prompt` + *Example*: `bin/solr start -e cloud --no-prompt` -`--prompts `:: +`--prompt-inputs `:: + [%autowidth,frame=none] |=== @@ -286,9 +286,9 @@ If you want to accept all of the defaults, you can simply add the `--no-prompt` + Don't prompt for input; provide defaults in comma delimited format when running examples that accept user input. + -For example, when using the "cloud" example, can start a three node cluster on specific ports: +For example, when using the "cloud" example, start a three node cluster on specific ports: + -*Example*: `bin/solr start -e cloud --prompts 3,9000,9001,9002,"mycollection",2,2,_defaults` +*Example*: `bin/solr start -e cloud --prompt-inputs 3,9000,9001,9002,"mycollection",2,2,_defaults` On Windows please wrap the prompts value in double quotes to preserve the comma delimited format. From 64c2a3cf7fd4ec5ac92a7f205e4f1ab8b996082f Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Tue, 17 Feb 2026 06:20:20 -0500 Subject: [PATCH 11/13] Fix example! --- .../deployment-guide/pages/solr-control-script-reference.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.adoc index 9074bfc3f6ba..69cd869abfdd 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 @@ -288,7 +288,7 @@ Don't prompt for input; provide defaults in comma delimited format when running + For example, when using the "cloud" example, start a three node cluster on specific ports: + -*Example*: `bin/solr start -e cloud --prompt-inputs 3,9000,9001,9002,"mycollection",2,2,_defaults` +*Example*: `bin/solr start -e cloud --prompt-inputs 3,9000,9001,9002,"mycollection",2,2,_default` On Windows please wrap the prompts value in double quotes to preserve the comma delimited format. From 5236af7d5e19b64c7a8ef3f90ad1bc671c6da57c Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 18 Feb 2026 06:05:00 -0500 Subject: [PATCH 12/13] fix messaging --- .../src/test/org/apache/solr/cli/TestSolrCLIRunExample.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java index e4c5d5187cb3..298bbfb0644e 100644 --- a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java +++ b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java @@ -585,7 +585,7 @@ public void testSolrCloudExampleWithPrompts() throws Exception { String solrUrl = "http://localhost:" + bindPort + "/solr"; if (!CLIUtils.safeCheckCollectionExists(solrUrl, collectionName, null)) { fail( - "After running Solr cloud example with --prompts, test collection '" + "After running Solr cloud example with --prompt-inputs, test collection '" + collectionName + "' not found in Solr at: " + solrUrl From 874798c88b8dd21448c9e5ebe53198a84a5a93fc Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 18 Feb 2026 06:05:05 -0500 Subject: [PATCH 13/13] Better docs --- .../pages/solr-control-script-reference.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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.adoc index 69cd869abfdd..a7348059cc2e 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 @@ -270,7 +270,7 @@ See the section <> below for more details o |Optional |Default: none |=== + -Don't prompt for input; accept all defaults when running examples that accept user input. +Don't prompt for input; accept all defaults when running examples that accept input. + For example, when using the "cloud" example, an interactive session guides you through several options for your SolrCloud cluster. If you want to accept all of the defaults, you can simply add the `--no-prompt` option to your request. @@ -284,9 +284,9 @@ If you want to accept all of the defaults, you can simply add the `--no-prompt` |Optional |Default: none |=== + -Don't prompt for input; provide defaults in comma delimited format when running examples that accept user input. +Don't prompt for input; instead supply ordered answers in comma delimited format when running examples that accept input. + -For example, when using the "cloud" example, start a three node cluster on specific ports: +For example, when using the "cloud" example, you can answer the prompts non-interactively to start a three node cluster on specific ports: + *Example*: `bin/solr start -e cloud --prompt-inputs 3,9000,9001,9002,"mycollection",2,2,_default`