I am using docker approach with Sitecore V10.2. I am trying to create a custom index with it's associated schema.
I followed following article as the reference point : Add your custom index to Solr in Sitecore Docker like a boss(goon)
Although, it seems like the article was written for Sitecore V10.0(Initial Release) docker solution. With V10.2, all the solr initialization steps(scripts) have been moved into the solr-init container also the script names & content is also changed.
I was able to locate one script which seems like can be used to create a custom index.
New-SolrCore.ps1 :
param(
[Parameter(Mandatory)]
[string]$SolrEndpoint,
[Parameter(Mandatory)]
[string[]]$SolrCoreNames,
[Parameter(Mandatory)]
[string]$SolrCorePrefix,
[Parameter(Mandatory)]
[string]$SolrConfigsetName,
[Parameter(Mandatory)]
[string]$SolrReplicationFactor,
[Parameter(Mandatory)]
[string]$SolrNumberOfShards,
[Parameter(Mandatory)]
[string]$SolrMaxShardNumberPerNode,
$SolrCollectionAliases
)
function Invoke-SolrWebRequest {
param (
[Parameter(Mandatory)]
[string]$Uri
)
return Invoke-RestMethod -Credential (Get-SolrCredential) -Uri $Uri `
-ContentType "application/json" -Method Post
}
foreach($solrCoreName in $SolrCoreNames) {
$solrCollectionName = ('{0}{1}' -f $SolrCorePrefix, $solrCoreName)
Write-Host "Creating $solrCollectionName SOLR collection"
$solrUrl = [System.String]::Concat($SolrEndpoint, "/admin/collections?action=CREATE&name=", $solrCollectionName ,
"&collection.configName=", $SolrConfigsetName, "&replicationFactor=", $SolrReplicationFactor,
"&numShards=", $SolrNumberOfShards, "&maxShardsPerNode=", $SolrMaxShardNumberPerNode, "&property.update.autoCreateFields=false")
$null = Invoke-SolrWebRequest -Uri $solrUrl
if( $SolrCollectionAliases.$solrCoreName ) {
$aliasName = '{0}{1}' -f $SolrCorePrefix, $SolrCollectionAliases.$solrCoreName
.\New-SolrAlias.ps1 -SolrEndpoint $SolrEndpoint -SolrCollectionName $solrCollectionName -AliasName $aliasName
}
}
So, I made a few changes suggested in the mentioned article to my Dockerfile according to the parameters of New-SolrCore.ps1 script expected parameters.
Following is my DockerFile changes for the custom solr-init image :
DockerFile :
# escape=`
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY customCores/custom_master_index C:\custom_master_index
RUN C:\New-SolrCore.ps1 -SolrEndpoint C:\data -SolrCoreNames '_custom_master_index' -SolrCorePrefix 'sitecore' -SolrConfigsetName C:\custom_master_index\managed-schema -SolrReplicationFactor '1' -SolrNumberOfShards '1' -SolrMaxShardNumberPerNode '1' ; `
Remove-Item -Path C:\custom_master_index -Recurse -Force;
After doing all these steps, I am getting following error & hence solution is not getting built :
Also, I am not using any custom script, I have been running the script (New-SolrCore.ps1) which is already a part of default solr-init running container.
Can anyone please help me out?
Thanks.