Wednesday, May 16, 2018

Switch Sitecore Lucene Config to Solr the elegant way

When you need to switch your Sitecore instance from Lucene to Solr, you need to disable all Lucene config files and enable the Solr ones. 

Step-by-step guide

Insert your steps.
  1. Open up a powershell window
  2. Change directory to your instance's App_Config\Include 
  3. Execute the following commands:
    1. Disable Lucene Configs
      Dir *.Lucene.*.config -Recurse | % { Rename-Item -Path $_.PSPath -NewName $_.Name.replace(".config",".config.disabled")}
    2. Enable Solr Configs
      Dir *.Solr.*.disabled -Recurse | % { Rename-Item -Path $_.PSPath -NewName $_.Name.replace(".disabled","")}
      Dir *.Solr.*.example -Recurse | % { Rename-Item -Path $_.PSPath -NewName $_.Name.replace(".example","")}
Batch file for easy use: