Apache Lucene open-source search software
SOLR-11108: Shorten/improve _default-configset msg
Jason Gerlowskib4f8cd7ea6bc
diff --git a/solr/bin/solr b/solr/bin/solrindex 1ef18fc68c8..4e178de9450 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -295,7 +295,7 @@ function print_usage() {if [ -z "$CMD" ]; thenecho ""echo "Usage: solr COMMAND OPTIONS"- echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert"+ echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config"echo ""echo " Standalone server example (start Solr running in the background on port 8984):"echo ""@@ -895,6 +895,11 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; thenexit $?fi+if [[ "$SCRIPT_CMD" == "config" ]]; then+ run_tool config $*+ exit $?+fi+# create a core or collectionif [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMD" == "create_collection" ]]; then@@ -1015,11 +1020,8 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMfiif [[ "$CREATE_CONFDIR" == "_default" ]] && ([[ "$CREATE_CONFNAME" == "" ]] || [[ "$CREATE_CONFNAME" == "_default" ]]); then- 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 " curl http://$SOLR_TOOL_HOST:$CREATE_PORT/solr/$CREATE_NAME/config -d '{\"set-user-property\": {\"update.autoCreateFields\":\"false\"}}'"+ echo "WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use."+ echo " To turn off: bin/solr config -c $CREATE_NAME -p $CREATE_PORT -property update.autoCreateFields -value false"fiif [[ "$(whoami)" == "root" ]] && [[ "$FORCE" == "false" ]] ; thendiff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex 40a0cf38510..dcff0c6af7a 100644--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -200,6 +200,7 @@ IF "%1"=="version" goto get_versionIF "%1"=="-v" goto get_versionIF "%1"=="-version" goto get_versionIF "%1"=="assert" goto run_assert+if "%1"=="config" goto run_configREM Only allow the command to be the first argument, assume start if not suppliedIF "%1"=="start" goto set_script_cmd@@ -268,7 +269,7 @@ goto done:script_usage@echo.@echo Usage: solr COMMAND OPTIONS-@echo where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert+@echo where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config@echo.@echo Standalone server example (start Solr running in the background on port 8984):@echo.@@ -1363,6 +1364,16 @@ if errorlevel 1 ()goto done+:run_config+"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^+ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^+ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^+ org.apache.solr.util.SolrCLI %*+if errorlevel 1 (+ exit /b 1+)+goto done+:get_version"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^@@ -1475,10 +1486,8 @@ if "!CREATE_PORT!"=="" ()if "!CREATE_CONFDIR!"=="_default" (- echo WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is- echo NOT RECOMMENDED for production use.- echo To turn it off:- echo curl http://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr/!CREATE_NAME!/config -d '{"set-user-property": {"update.autoCreateFields":"false"}}'+ echo WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.+ echo To turn off: bin\solr config -c !CREATE_NAME! -p !CREATE_PORT! -property update.autoCreateFields -value false)if "%SCRIPT_CMD%"=="create_core" (diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.javaindex f4cd7c7823f..266ef3a28a3 100644--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java@@ -238,7 +238,8 @@ public class SolrCLI {.hasArg().isRequired(false).withDescription("Name of collection; no default")- .create("collection"),+ .withLongOpt("collection")+ .create("c"),OptionBuilder.isRequired(false).withDescription("Enable more verbose command output.")@@ -2525,13 +2526,39 @@ public class SolrCLI {.hasArg().isRequired(false).withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")- .create("solrUrl")+ .create("solrUrl"),+ OptionBuilder+ .withArgName("PORT")+ .hasArg()+ .isRequired(false)+ .withDescription("The port of the Solr node to use when applying configuration change")+ .withLongOpt("port")+ .create('p'),+ OptionBuilder+ .withArgName("SCHEME")+ .hasArg()+ .isRequired(false)+ .withDescription("The scheme for accessing Solr. Accepted values: http or https. Default: http")+ .withLongOpt("scheme")+ .create('s')};return joinOptions(configOptions, cloudOptions);}protected void runImpl(CommandLine cli) throws Exception {- String solrUrl = resolveSolrUrl(cli);+ String solrUrl;+ try {+ solrUrl = resolveSolrUrl(cli);+ } catch (IllegalStateException e) {+ // Fallback to using the provided scheme and port+ final String scheme = cli.getOptionValue("scheme", "http");+ if (cli.hasOption("port")) {+ solrUrl = scheme + "://localhost:" + cli.getOptionValue("port", "8983") + "/solr";+ } else {+ throw e;+ }+ }+String action = cli.getOptionValue("action", "set-property");String collection = cli.getOptionValue("collection", "gettingstarted");String property = cli.getOptionValue("property");