Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16672: Remove use of setDefaultCollection in SolrCLI (#1372)

Eric Pugh9ca0dbaf7661
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d20115bca00..6e8c731cf7a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -309,6 +309,8 @@ Other Changes
* SOLR-15928: Dim 'Add Collection' and 'Create Alias' buttons when user lacks proper permissions (janhoy)
+* SOLR-16672: Simplify SolrCLI Healthcheck command's logic for obtaining a target collection (Eric Pugh)
+
================== 9.1.1 ==================
Bug Fixes
diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
index c7112bf6608..546a0f50bca 100755
--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
@@ -211,9 +211,6 @@ public class SolrCLI implements CLIO {
new CloudLegacySolrClient.Builder(Collections.singletonList(zkHost), Optional.empty())
.build()) {
- String collection = cli.getOptionValue("collection");
- if (collection != null) cloudSolrClient.setDefaultCollection(collection);
-
cloudSolrClient.connect();
runCloudTool(cloudSolrClient, cli);
}
@@ -592,7 +589,7 @@ public class SolrCLI implements CLIO {
* Tries a simple HEAD request and throws SolrException in case of Authorization error
*
* @param url the url to do a HEAD request to
- * @param httpClient the http client to use (make sure it has authentication optinos set)
+ * @param httpClient the http client to use (make sure it has authentication options set)
* @return the HTTP response code
* @throws SolrException if auth/autz problems
* @throws IOException if connection failure
@@ -1273,7 +1270,7 @@ public class SolrCLI implements CLIO {
SolrQuery q = new SolrQuery("*:*");
q.setRows(0);
- QueryResponse qr = cloudSolrClient.query(q);
+ QueryResponse qr = cloudSolrClient.query(collection, q);
String collErr = null;
long docCount = -1;
try {
diff --git a/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
index 320c0000d10..855e85e0c54 100644
--- a/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
+++ b/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
@@ -324,6 +324,12 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {
testExample("schemaless");
}
+ @Test
+ @LuceneTestCase.Nightly
+ public void testFilmsExample() throws Exception {
+ testExample("films");
+ }
+
protected void testExample(String exampleName) throws Exception {
File solrHomeDir = new File(ExternalPaths.SERVER_HOME);
if (!solrHomeDir.isDirectory())