Pipelines/Steps/Install/OnPrem/Sitecore/XM/Solr/9.1/Create-CustomSolrCores.ps1

$ErrorActionPreference = "Stop"

Write-Output "Add custom Solr cores started..."

if (($null -eq $SAFConfiguration.search.solr.customCores) -or ($SAFConfiguration.search.solr.customCores.Count -lt 1)) {
    Write-Output "No custom Solr cores found."
}
else {
    $prefix = $SAFConfiguration.prefix
    $configPath = "$PSScriptRoot\custom-solr.json"
    $solrService = $SAFConfiguration.search.solr.install.serviceName

    foreach ($index in $SAFConfiguration.search.solr.customCores) {
        $solrParams = @{
            Path        = $configPath
            SolrUrl     = $SAFSolrServiceURL
            SolrRoot    = $SAFSolrServiceDir
            SolrService = $solrService
            CorePrefix  = $prefix  
            CoreName    = $index.name
        }
        Install-SitecoreConfiguration @solrParams
    }
}

Write-Output "Add custom Solr cores done."