This is an automated email from the ASF dual-hosted git repository. epugh pushed a commit to branch branch_9x in repository https://gitbox.apache.org/repos/asf/solr.git
commit a6d94f21340a5625e0ab2ea48aac676d075d905b Author: Eric Pugh <[email protected]> AuthorDate: Fri Feb 23 13:55:20 2024 -0500 SOLR-17017: Reset the collection as part of running the example when starting Solr... (#2261) Provide some messaging about running an example via bin/solr start -e MYEXAMPLE and the example already exists warning the user that the state isnt' fresh! --- .../java/org/apache/solr/cli/RunExampleTool.java | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) 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 680a879372e..f6e81b57af5 100644 --- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java +++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java @@ -259,15 +259,18 @@ public class RunExampleTool extends ToolBase { String solrUrl = (String) nodeStatus.get("baseUrl"); - // safe check if core / collection already exists + // If the example already exists then let the user know they should delete it or + // they may get unusual behaviors. boolean alreadyExists = false; - if (nodeStatus.get("cloud") != null) { - if (SolrCLI.safeCheckCollectionExists(solrUrl, collectionName)) { + boolean cloudMode = nodeStatus.get("cloud") != null; + if (cloudMode) { + if (SolrCLI.safeCheckCollectionExists( + solrUrl, collectionName))) { alreadyExists = true; echo( "\nWARNING: Collection '" + collectionName - + "' already exists!\nChecked collection existence using Collections API"); + + "' already exists, which may make starting this example not work well!"); } } else { String coreName = collectionName; @@ -276,10 +279,17 @@ public class RunExampleTool extends ToolBase { echo( "\nWARNING: Core '" + coreName - + "' already exists!\nChecked core existence using Core API command"); + + "' already exists, which may make starting this example not work well!"); } } + if (alreadyExists) { + echo( + "You may want to run 'bin/solr delete -c " + + collectionName + + "' first before running the example to ensure a fresh state."); + } + if (!alreadyExists) { String[] createArgs = new String[] { @@ -335,7 +345,7 @@ public class RunExampleTool extends ToolBase { } } else if ("films".equals(exampleName) && !alreadyExists) { try (SolrClient solrClient = new Http2SolrClient.Builder(solrUrl).build()) { - echo("Adding dense vector field type to films schema \"_default\""); + echo("Adding dense vector field type to films schema"); SolrCLI.postJsonToSolr( solrClient, "/" + collectionName + "/schema", @@ -349,8 +359,7 @@ public class RunExampleTool extends ToolBase { + " }\n" + " }"); - echo( - "Adding name, initial_release_date, and film_vector fields to films schema \"_default\""); + echo("Adding name, initial_release_date, and film_vector fields to films schema"); SolrCLI.postJsonToSolr( solrClient, "/" + collectionName + "/schema",
