omitHeader=true|false
wt=json|xml
indent=true|false
private void listCollections(final int jettyPort) throws IOException { final String url = "http://localhost:" + jettyPort + "/solr/admin/collections?action=List"; final HttpGet request = new HttpGet(url); try (final CloseableHttpClient client = HttpClientBuilder.create().build(); final CloseableHttpResponse response = client.execute(request)) { final HttpEntity entity = response.getEntity(); System.out.println(IOUtils.toString(entity.getContent(), "UTF-8")); // close the content stream. EntityUtils.consumeQuietly(entity); } }
_default
").<response> <lst name="success"> <lst name="192.168.2.33:8984_solr"> <lst name="responseHeader"> <int name="status">0</int> <int name="QTime">2176</int> </lst> <str name="core">collection1_shard1_replica_n1</str> </lst> <lst name="192.168.2.33:8984_solr"> <lst name="responseHeader"> <int name="status">0</int> <int name="QTime">2174</int> </lst> <str name="core">collection1_shard2_replica_n4</str> </lst> <lst name="192.168.2.33:8983_solr"> <lst name="responseHeader"> <int name="status">0</int> <int name="QTime">2557</int> </lst> <str name="core">collection1_shard1_replica_n2</str> </lst> <lst name="192.168.2.33:8983_solr"> <lst name="responseHeader"> <int name="status">0</int> <int name="QTime">2594</int> </lst> <str name="core">collection1_shard2_replica_n6</str> </lst> </lst> </response>
private void createCollection(final int jettyPort, final String collectionName, final int numShards, final int numReplicas, final int maxShardsPerNode, final String configSetName) throws IOException { final String url = "http://localhost:" + jettyPort + "/solr/admin/collections?action=CREATE" + "&name=" + collectionName + "&numShards=" + numShards + "&replicationFactor=" + numReplicas + "&maxShardsPerNode=" + maxShardsPerNode + "&collection.configName=" + configSetName; final HttpGet request = new HttpGet(url); try (final CloseableHttpClient client = HttpClientBuilder.create().build(); final CloseableHttpResponse response = client.execute(request)) { final HttpEntity entity = response.getEntity(); System.out.println(IOUtils.toString(entity.getContent(), "UTF-8")); // close the content stream. EntityUtils.consumeQuietly(entity); } }
private void deleteCollection(final int jettyPort, final String collectionName) throws IOException { final String url = "http://localhost:" + jettyPort + "/solr/admin/collections?action=DELETE" + "&name=" + collectionName; final HttpGet request = new HttpGet(url); try (final CloseableHttpClient client = HttpClientBuilder.create().build(); final CloseableHttpResponse response = client.execute(request)) { final HttpEntity entity = response.getEntity(); System.out.println(IOUtils.toString(entity.getContent(), "UTF-8")); // close the content stream. EntityUtils.consumeQuietly(entity); } }
RELOAD
" action can be used if you the change the collection configuration in ZooKeeper.private void reloadCollection(final int jettyPort, final String collectionName) throws IOException { final String url = "http://localhost:" + jettyPort + "/solr/admin/collections?action=RELOAD" + "&name=" + collectionName; final HttpGet request = new HttpGet(url); try (final CloseableHttpClient client = HttpClientBuilder.create().build(); final CloseableHttpResponse response = client.execute(request)) { final HttpEntity entity = response.getEntity(); System.out.println(IOUtils.toString(entity.getContent(), "UTF-8")); // close the content stream. EntityUtils.consumeQuietly(entity); } }