SolrNet offers some facilities to execute Solr core admin commands. See the Solr wiki for detailed explanations of these commands.
First, build an instance of ISolrCoreAdmin
:
const string solrUrl = "http://localhost"8983/solr";
var headerParser = ServiceLocator.Current.GetInstance<ISolrHeaderResponseParser>();
var statusParser = ServiceLocator.Current.GetInstance<ISolrStatusResponseParser>();
ISolrCoreAdmin solrCoreAdmin = new SolrCoreAdmin(new SolrConnection(solrUrl), headerParser, statusParser);
ISolrCoreAdmin
can execute the following core admin commands:
/// Get the status of all registered cores:
IList<CoreResult> coreStatus = solrCoreAdmin.Status();
/// Get the status of a single core:
var coreStatus = solrCoreAdmin.Status("core1");
solrCoreAdmin.Create(coreName: "items", instanceDir: "items");
solrCoreAdmin.Reload("core1");
solrCoreAdmin.Rename("core1", "newCoreName");
solrCoreAdmin.Swap("core0", "core1");
solrCoreAdmin.Swap("core0", UnloadCommand.Delete.Data);
solrCoreAdmin.Merge("destinationCore", new MergeCommand.SrcCore("sourceCore0"), new MergeCommand.SrcCore("sourceCore1"));
solrCoreAdmin.Alias("existingCore", "alias");