Pipelines/Steps/Install/OnPrem/Solr/Create-RebuildCores.ps1

$ErrorActionPreference = "Stop"

Write-Output "Create Solr rebuild cores started..."

if (($null -eq $SAFConfiguration.search.solr.rebuildCores) -or ($SAFConfiguration.search.solr.rebuildCores.Count -lt 1)) {
    Write-Output "No rebuild cores defined. Skipping..."
}
else {
    StopWindowsService -Service $SAFConfiguration.search.solr.serviceName
    foreach ($rebuildCore in $SAFConfiguration.search.solr.rebuildCores) {
        $fullOriginalCoreName = "$($SAFConfiguration.prefix)_$($rebuildCore)"
        DuplicateConfigSet -SolrRootDir $SAFSolrServiceDir -OriginalCoreName $fullOriginalCoreName
    }
    StartWindowsService -Service $SAFConfiguration.search.solr.serviceName
}

Write-Output "Create Solr rebuild cores done."