Home
Cloud
Big Data
CI
Install
Samples
Java
Ubuntu
Maven
Archive
Apache Solr
|
SolrJ: CollectionAdminRequest API - Aliases
Notes
Create Alias: CollectionAdminRequest::CreateAlias
Delete Alias: CollectionAdminRequest::DeleteAlias
Notes
In order for the code bellow to work:
► Make sure to update the variables ("
solrUrl
", "
collectionName
", ...) with your information.
Create Alias: CollectionAdminRequest::CreateAlias
final String[] solrUrl = { "http://localhost:8983/solr" }; final CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder(Arrays.asList(solrUrl)).build(); final String aliasName = "alias1"; final String aliasedCollections = "collection1,collection2"; // create alias { final CollectionAdminRequest.CreateAlias adminRequest = CollectionAdminRequest.CreateAlias.createAlias(aliasName, aliasedCollections); CollectionAdminResponse adminResponse = adminRequest.process(cloudSolrClient); System.out.println(adminResponse); } cloudSolrClient.close();
Delete Alias: CollectionAdminRequest::DeleteAlias
final String[] solrUrl = { "http://localhost:8983/solr" }; final CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder(Arrays.asList(solrUrl)).build(); final String aliasName = "alias1"; // delete alias { final CollectionAdminRequest.DeleteAlias adminRequest = CollectionAdminRequest.DeleteAlias.deleteAlias(aliasName); CollectionAdminResponse adminResponse = adminRequest.process(cloudSolrClient); System.out.println(adminResponse); } cloudSolrClient.close();
© 2010-2022
mti
tek