@@ -264,16 +264,18 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
264264
265265 String solrUrl = (String ) nodeStatus .get ("baseUrl" );
266266
267- // safe check if core / collection already exists
267+ // If the example already exists then let the user know they should delete it or
268+ // they may get unusual behaviors.
268269 boolean alreadyExists = false ;
269- if (nodeStatus .get ("cloud" ) != null ) {
270+ boolean cloudMode = nodeStatus .get ("cloud" ) != null ;
271+ if (cloudMode ) {
270272 if (SolrCLI .safeCheckCollectionExists (
271273 solrUrl , collectionName , cli .getOptionValue (SolrCLI .OPTION_CREDENTIALS .getLongOpt ()))) {
272274 alreadyExists = true ;
273275 echo (
274276 "\n WARNING: Collection '"
275277 + collectionName
276- + "' already exists! \n Checked collection existence using Collections API " );
278+ + "' already exists, which may make starting this example not work well! " );
277279 }
278280 } else {
279281 String coreName = collectionName ;
@@ -283,10 +285,17 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
283285 echo (
284286 "\n WARNING: Core '"
285287 + coreName
286- + "' already exists! \n Checked core existence using Core API command " );
288+ + "' already exists, which may make starting this example not work well! " );
287289 }
288290 }
289291
292+ if (alreadyExists ) {
293+ echo (
294+ "You may want to run 'bin/solr delete -c "
295+ + collectionName
296+ + "' first before running the example to ensure a fresh state." );
297+ }
298+
290299 if (!alreadyExists ) {
291300 String [] createArgs =
292301 new String [] {
@@ -342,7 +351,7 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
342351 }
343352 } else if ("films" .equals (exampleName ) && !alreadyExists ) {
344353 try (SolrClient solrClient = new Http2SolrClient .Builder (solrUrl ).build ()) {
345- echo ("Adding dense vector field type to films schema \" _default \" " );
354+ echo ("Adding dense vector field type to films schema" );
346355 SolrCLI .postJsonToSolr (
347356 solrClient ,
348357 "/" + collectionName + "/schema" ,
@@ -356,8 +365,7 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
356365 + " }\n "
357366 + " }" );
358367
359- echo (
360- "Adding name, initial_release_date, and film_vector fields to films schema \" _default\" " );
368+ echo ("Adding name, initial_release_date, and film_vector fields to films schema" );
361369 SolrCLI .postJsonToSolr (
362370 solrClient ,
363371 "/" + collectionName + "/schema" ,
0 commit comments