Home
Cloud
Big Data
CI
Install
Samples
Java
Ubuntu
Maven
Archive
Apache Solr
|
Solr HTTP Admin API: Collections API - Aliases
Notes
Create an Alias
Delete an Alias
Notes
See this page for more details about the Collections API:
https://lucene.apache.org/solr/guide/8_5/collections-api.html
Create an Alias
HTTP Request (URL)
:
http://localhost:8983/solr/admin/collections?action=CREATEALIAS&name=collection_1_2_alias&collections=collection1,collection2
Java sample
:
private void createAlias(final int jettyPort, final String aliasName, final String aliasedCollections) throws IOException { final String url = "http://localhost:" + jettyPort + "/solr/admin/collections?action=CREATEALIAS" + "&name=" + aliasName + "&collections=" + aliasedCollections; 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); } }
Delete an Alias
HTTP Request (URL)
:
http://localhost:8983/solr/admin/collections?action=DELETEALIAS&name=collection_1_2_alias
Java sample
:
private void deleteAlias(final int jettyPort, final String aliasName) throws IOException { final String url = "http://localhost:" + jettyPort + "/solr/admin/collections?action=DELETEALIAS" + "&name=" + aliasName; 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); } }
© 2010-2022
mti
tek