Create and configure xdb indexes for Solr in Sitecore
When working on Sitecore personalization, sometimes we have seen the challenges related to profile interaction and personalization reports data is not correct.
Here's the common issue: your xdb indexes either are not up to date or they are not configured properly. In this article I am going explain you how to create and configure xdb indexes for SOLR search.
1. Create SOLR Cores
- Make 2 copies of Solr _default configurations from the <SolrDirectory>\server\solr\configset\_default folder. Put the copies in the <SolrDirectory>\server\solr folder.
- Rename the cores <custom_name> and <custom_name>_rebuild, for example: xdb and xdb_rebuild.
- Change your cores settings based on your required
index names for SOLR xdb cors. Remove additional data inside cors data folder.
Note: keep all folders inside the data folder and only remove the data. - Restart your SOLR service (open services.msc >> search SOLR service >> right click and restart it)
- Update SOLR schema in xconnect-search-instance using the schema file located on <xconnect-search-instance>\App_data\solrcommands\schema.json. Schema update should apply for new xdb cors.
You can use the below PowerShell script
that uses the Solr Schema API to apply the changes:
Note: If your Sitecore is hosted in Azure
you can go to <xconnect-search-instance> kudo powershell console
to run the powershell command.
- Create a powershell file (eg: “solrschemaupdate.ps1”) with below script.
- Open powershell in admin mode within your SOLR instance
- Go to your powershell file location
- Run your powershell command (eg: “.\solrschemaupdate.ps1”)
$apiUrl="<solr-url>/ATCC_xdb/schema"
$requestBody = Get-Content $pathToXdbSchemaFile -Raw
Write-Host "Executing Solr commands:" $requestBody
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $apiUrl -ContentType "application/json" -Method Post -Body $requestBody | Write-Host
2. Enable SOLR configurations in xconnect instance
- Make sure “***.AzureSearch.xml” files are disabled and “SOLR.xml” files are enabled in <xconnect-instance> instance.
- Specify the solrCore connection string with the name of core attached to Solr in below configuration files.
<xconnect-instance>\App_Config\ConnectionStrings.config
<xconnect-instance>\App_data\jobs\continuous\IndexWorker\App_config\ ConnectionStrings.config
The node you update looks like this:
<add name="solrCore" connectionString="https://<host>:<port>/solr/<custom_name>"/>
Note: Replace <custom_name> with your SOLR xdb core name.
3
Hope you enjoyed it !! 😊




Comments
Post a Comment