Apache Solr open-source search software
SOLR-17556: Examples should run with the standard & recommended Solr home and solr data dir (#2861)
Eric Pugh620175a5626e
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex ea10c72378b..666958c64da 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -247,6 +247,8 @@ led to the suppression of exceptions. (Andrey Bozhko)* SOLR-17504: CoreContainer calls UpdateHandler.commit when closing a read-only core (Bruno Roustant)+* SOLR-17556: "home" and "data" directories used by Solr examples have been updated to align with documented best practices. (Eric Pugh, Houston Putman)+================== 9.7.1 ==================Bug Fixes---------------------diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.javaindex fff3c04f5c5..4f0346c6079 100644--- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java+++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java@@ -46,7 +46,6 @@ import org.apache.commons.exec.environment.EnvironmentUtils;import org.apache.commons.io.FileUtils;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.impl.CloudSolrClient;-import org.apache.solr.client.solrj.impl.Http2SolrClient;import org.apache.solr.common.SolrException;import org.noggit.CharArr;import org.noggit.JSONWriter;@@ -266,7 +265,6 @@ public class RunExampleTool extends ToolBase {}protected void runExample(CommandLine cli, String exampleName) throws Exception {- File exDir = setupExampleDir(serverDir, exampleDir, exampleName);String collectionName = "schemaless".equals(exampleName) ? "gettingstarted" : exampleName;String configSet ="techproducts".equals(exampleName) ? "sample_techproducts_configs" : "_default";@@ -277,9 +275,9 @@ public class RunExampleTool extends ToolBase {Integer.parseInt(cli.getOptionValue(PORT_OPTION, System.getenv().getOrDefault("SOLR_PORT", "8983")));Map<String, Object> nodeStatus =- startSolr(new File(exDir, "solr"), isCloudMode, cli, port, zkHost, 30);+ startSolr(new File(serverDir, "solr"), isCloudMode, cli, port, zkHost, 30);- String solrUrl = (String) nodeStatus.get("baseUrl");+ String solrUrl = CLIUtils.normalizeSolrUrl((String) nodeStatus.get("baseUrl"));// If the example already exists then let the user know they should delete it, or// they may get unusual behaviors.@@ -310,7 +308,7 @@ public class RunExampleTool extends ToolBase {echo("You may want to run 'bin/solr delete -c "+ collectionName- + "' first before running the example to ensure a fresh state.");+ + " --delete-config' first before running the example to ensure a fresh state.");}if (!alreadyExists) {@@ -333,7 +331,7 @@ public class RunExampleTool extends ToolBase {if ("techproducts".equals(exampleName) && !alreadyExists) {- File exampledocsDir = new File(exampleDir, "exampledocs");+ File exampledocsDir = new File(this.exampleDir, "exampledocs");if (!exampledocsDir.isDirectory()) {File readOnlyExampleDir = new File(serverDir.getParentFile(), "example");if (readOnlyExampleDir.isDirectory()) {@@ -364,7 +362,9 @@ public class RunExampleTool extends ToolBase {"exampledocs directory not found, skipping indexing step for the techproducts example");}} else if ("films".equals(exampleName) && !alreadyExists) {- try (SolrClient solrClient = new Http2SolrClient.Builder(solrUrl).build()) {+ try (SolrClient solrClient =+ CLIUtils.getSolrClient(+ solrUrl, cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION))) {echo("Adding dense vector field type to films schema");SolrCLI.postJsonToSolr(solrClient,@@ -424,7 +424,7 @@ public class RunExampleTool extends ToolBase {+ " }\n"+ " }\n");- File filmsJsonFile = new File(exampleDir, "films/films.json");+ File filmsJsonFile = new File(this.exampleDir, "films/films.json");echo("Indexing films example docs from " + filmsJsonFile.getAbsolutePath());String[] args =new String[] {@@ -549,8 +549,7 @@ public class RunExampleTool extends ToolBase {new File(cloudDir, "node" + (n + 1) + "/solr"), true, cli, cloudPorts[n], zkHost, 30);}- String solrUrl = (String) nodeStatus.get("baseUrl");- if (solrUrl.endsWith("/")) solrUrl = solrUrl.substring(0, solrUrl.length() - 1);+ String solrUrl = CLIUtils.normalizeSolrUrl((String) nodeStatus.get("baseUrl"), false);// wait until live nodes == numNodeswaitToSeeLiveNodes(zkHost, numNodes);diff --git a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.javaindex da279a12301..6da81edaa29 100644--- a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java+++ b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java@@ -403,15 +403,6 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {// dump all the output written by the SolrCLI commands to stdout// System.out.println("\n\n"+toolOutput+"\n\n");- File exampleSolrHomeDir = new File(solrExampleDir, exampleName + "/solr");- assertTrue(- exampleSolrHomeDir.getAbsolutePath()- + " not found! run "- + exampleName- + " example failed; output: "- + toolOutput,- exampleSolrHomeDir.isDirectory());-if ("techproducts".equals(exampleName)) {try (SolrClient solrClient =getHttpSolrClient("http://localhost:" + bindPort + "/solr", exampleName)) {diff --git a/solr/server/resources/log4j2-console.xml b/solr/server/resources/log4j2-console.xmlindex c33c93c9327..2d5b8690bf6 100644--- a/solr/server/resources/log4j2-console.xml+++ b/solr/server/resources/log4j2-console.xml@@ -16,9 +16,9 @@limitations under the License.-->-<!-- Use this file for logging exlusively to the console, useful for+<!-- Use this file for logging exclusively to the console, useful forsome development tasks. Should not be used for production -->-<!-- Default production configuration is asnychronous logging -->+<!-- Default production configuration is asynchronous logging --><Configuration><Appenders><Console name="STDERR" target="SYSTEM_ERR">diff --git a/solr/server/resources/log4j2.xml b/solr/server/resources/log4j2.xmlindex 006de0c965c..f5b373338b7 100644--- a/solr/server/resources/log4j2.xml+++ b/solr/server/resources/log4j2.xml@@ -16,7 +16,7 @@limitations under the License.-->-<!-- Default production configuration is asnychronous logging -->+<!-- Default production configuration is asynchronous logging --><Configuration><Appenders>@@ -62,7 +62,7 @@</Appenders><Loggers>- <!-- Use <AsyncLogger/<AsyncRoot and <Logger/<Root for asynchronous logging or synchonous logging respectively -->+ <!-- Use <AsyncLogger/<AsyncRoot and <Logger/<Root for asynchronous logging or synchronous logging respectively --><AsyncLogger name="org.apache.hadoop" level="warn"/><AsyncLogger name="org.apache.solr.update.LoggingInfoStream" level="off"/><AsyncLogger name="org.apache.zookeeper" level="warn"/>diff --git a/solr/server/solr/configsets/_default/conf/solrconfig.xml b/solr/server/solr/configsets/_default/conf/solrconfig.xmlindex 5bc2cf13415..3cec6a4e578 100644--- a/solr/server/solr/configsets/_default/conf/solrconfig.xml+++ b/solr/server/solr/configsets/_default/conf/solrconfig.xml@@ -37,51 +37,6 @@--><luceneMatchVersion>9.11</luceneMatchVersion>- <!-- <lib/> directives can be used to instruct Solr to load any Jars- identified and use them to resolve any "plugins" specified in- your solrconfig.xml or schema.xml (ie: Analyzers, Request- Handlers, etc...).-- All directories and paths are resolved relative to the- instanceDir.-- Please note that <lib/> directives are processed in the order- that they appear in your solrconfig.xml file, and are "stacked"- on top of each other when building a ClassLoader - so if you have- plugin jars with dependencies on other jars, the "lower level"- dependency jars should be loaded first.-- If a "./lib" directory exists in your instanceDir, all files- found in it are included as if you had used the following- syntax...-- <lib dir="./lib" />- -->-- <!-- A 'dir' option by itself adds any files found in the directory- to the classpath, this is useful for including all jars in a- directory.-- When a 'regex' is specified in addition to a 'dir', only the- files in that directory which completely match the regex- (anchored on both ends) will be included.-- If a 'dir' option (with or without a regex) is used and nothing- is found that matches, a warning will be logged.-- The example below can be used to load a Solr Module along- with their external dependencies.- -->- <!-- <lib dir="${solr.install.dir:../../../..}/modules/ltr/lib" regex=".*\.jar" /> -->-- <!-- an exact 'path' can be used instead of a 'dir' to specify a- specific jar file. This will cause a serious error to be logged- if it can't be loaded.- -->- <!--- <lib path="../a-jar-that-does-not-exist.jar" />- -->-<!-- Data DirectoryUsed to specify an alternate directory to hold all index datadiff --git a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xmlindex 8350831eeb9..0cf3a85a63c 100644--- a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml+++ b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml@@ -37,61 +37,6 @@--><luceneMatchVersion>9.11</luceneMatchVersion>- <!-- <lib/> directives can be used to instruct Solr to load any Jars- identified and use them to resolve any "plugins" specified in- your solrconfig.xml or schema.xml (ie: Analyzers, Request- Handlers, etc...).-- All directories and paths are resolved relative to the- instanceDir.-- Please note that <lib/> directives are processed in the order- that they appear in your solrconfig.xml file, and are "stacked"- on top of each other when building a ClassLoader - so if you have- plugin jars with dependencies on other jars, the "lower level"- dependency jars should be loaded first.-- If a "./lib" directory exists in your instanceDir, all files- found in it are included as if you had used the following- syntax...-- <lib dir="./lib" />- -->-- <!-- A 'dir' option by itself adds any files found in the directory- to the classpath, this is useful for including all jars in a- directory.-- When a 'regex' is specified in addition to a 'dir', only the- files in that directory which completely match the regex- (anchored on both ends) will be included.-- If a 'dir' option (with or without a regex) is used and nothing- is found that matches, a warning will be logged.-- The examples below can be used to load some Solr Modules along- with their external dependencies as an alternative to using a- startup parameter to define the modules to load globally. For more info- see https://solr.apache.org/guide/solr/latest/configuration-guide/solr-modules.html.- -->- <lib dir="${solr.install.dir:../../../..}/modules/extraction/lib" regex=".*\.jar" />-- <lib dir="${solr.install.dir:../../../..}/modules/clustering/lib/" regex=".*\.jar" />-- <lib dir="${solr.install.dir:../../../..}/modules/langid/lib/" regex=".*\.jar" />-- <lib dir="${solr.install.dir:../../../..}/modules/ltr/lib/" regex=".*\.jar" />-- <lib dir="${solr.install.dir:../../../..}/modules/scripting/lib/" regex=".*\.jar" />-- <!-- an exact 'path' can be used instead of a 'dir' to specify a- specific jar file. This will cause a serious error to be logged- if it can't be loaded.- -->- <!--- <lib path="../a-jar-that-does-not-exist.jar" />- -->-<!-- Data DirectoryUsed to specify an alternate directory to hold all index datadiff --git a/solr/solr-ref-guide/modules/query-guide/pages/learning-to-rank.adoc b/solr/solr-ref-guide/modules/query-guide/pages/learning-to-rank.adocindex ef4c519c34f..1d3f575ba03 100644--- a/solr/solr-ref-guide/modules/query-guide/pages/learning-to-rank.adoc+++ b/solr/solr-ref-guide/modules/query-guide/pages/learning-to-rank.adoc@@ -290,7 +290,7 @@ To enable the plugins, please specify the `solr.ltr.enabled` JVM System Property[source,bash]-----bin/solr start -e techproducts -Dsolr.ltr.enabled=true+bin/solr start -e techproducts -Dsolr.modules=ltr -Dsolr.ltr.enabled=true----=== Uploading Featuresdiff --git a/solr/solr-ref-guide/modules/query-guide/pages/result-clustering.adoc b/solr/solr-ref-guide/modules/query-guide/pages/result-clustering.adocindex 11433c6fa7c..541ea99c363 100644--- a/solr/solr-ref-guide/modules/query-guide/pages/result-clustering.adoc+++ b/solr/solr-ref-guide/modules/query-guide/pages/result-clustering.adoc@@ -123,7 +123,7 @@ To enable the clustering component extension and the dedicated search handler co[source,bash]-----bin/solr start -e techproducts -Dsolr.clustering.enabled=true+bin/solr start -e techproducts -Dsolr.modules=clustering -Dsolr.clustering.enabled=true----You can now try out the clustering handler by opening the following URL in a browser: