Sitecore 8 Azure PaaS Part 5 - SOLR Search in Azure

This is another optional step to get your Search functionality offloaded to a dedicated VM in Azure. Another advantage is that SOLR is built on Java Lucene; Sitecore’s out of the box Lucene Search uses the .NET version (which is an old port that is missing some functionality).

MS Azure has a SOLR VM you can spin up without too much trouble, here are the steps to get it going with Sitecore 8.1:

1) Add a new Virtual Machine, search for Apache Solr by Bitname and deploy this.

2) Use Putty to remote into the new VM.

3) You will need to remove the authentication for Solr:

https://community.bitnami.com/t/disable-remote-authentication-for-solr-urls/40702

i.e. you will need to remove the “location” section from this file:

sudo nano /opt/bitnami/apache-solr/conf/solr.conf

then restart Apache:

sudo /opt/bitnami/ctlscript.sh restart apache

4) In a web browser navigate to mysitename.cloudapp.azure.com/solr/

5) Download the SOLR support package from Sitecore, under the Additional Tools section of the download page:

https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform/Sitecore_81/Sitecore_Experience_Platform_81_Update3.aspx

6) Upload the DLL’s in here to the bin of your Web App.

7) In Putty navigate to  ~/stack/apache-solr/server/solr/configsets/ and use the following command:

sudo cp -R basic_configs sitecore_configs

8) Use an FTP program such as Filezilla to download the sitecore_configs to your local PC. Use an SFTP connection on port 22.

9) Refer to the support article below for the schema.xml changes you will need to apply. You will need to rename the “managed-schema” file to “schema.xml”.

Part of the process is to run the “Generate the Solr Schema.xml file” option inside Sitecore’s Control Panel; you will need a local dev instance of your site to run this.

https://kb.sitecore.net/articles/227897

You will also need to add these to the schema file after it is generated:


<dynamicField name=“*_t_de” type=“ignored” multiValued=“true” />
<dynamicField name=“*_t_da” type=“ignored” multiValued=“true” />
<dynamicField name=“*_t_ja” type=“ignored” multiValued=“true”  />

These will ignore these languages and not index them. To index these refer to the article linked at the bottom.

10) Here is a copy of the file with all changes applied and post Sitecore generation for Sitecore 8 Update 3 and Solr 5.5:

https://gist.github.com/blacktambourine/88fb6340bd946b4f8cb0d6b78fbb84be

11) Upload the file into the “sitecore_configs” folder. You will probably need to rename the file in Linux and change its permissions to be able to upload over the top of it:

sudo mv managed-schema schema.xml

sudo chmod a+w schema.xml

Note: Double check that the file has been renamed to schema.xml for each Core; you will get connection errors (i.e. "Connection error to search provider [Solr]“) in Sitecore if the filename is not named schema.xml. You will need to restart your Solr VM if changing the schema.xml later on.

12) Navigate up to the ~/stack/apache-solr/server/solr directory and run these commands to make a copy of the Sitecore configs for each index you will be running in Solr:

sudo cp -R ./configsets/sitecore_configs sitecore_web_index

sudo cp -R ./configsets/sitecore_configs sitecore_master_index

sudo cp -R ./configsets/sitecore_configs sitecore_core_index

sudo cp -R ./configsets/sitecore_configs sitecore_analytics_index

sudo cp -R ./configsets/sitecore_configs social_messages_web
sudo cp -R ./configsets/sitecore_configs social_messages_master
sudo cp -R ./configsets/sitecore_configs sitecore_testing_index
sudo cp -R ./configsets/sitecore_configs sitecore_suggested_test_index
sudo cp -R ./configsets/sitecore_configs sitecore_marketingdefinitions_web_index
sudo cp -R ./configsets/sitecore_configs sitecore_marketingdefinitions_master_index
sudo cp -R ./configsets/sitecore_configs sitecore_marketing_asset_index_web
sudo cp -R ./configsets/sitecore_configs sitecore_marketing_asset_index_master
sudo cp -R ./configsets/sitecore_configs sitecore_list_index
sudo cp -R ./configsets/sitecore_configs sitecore_fxm_web_index
sudo cp -R ./configsets/sitecore_configs sitecore_fxm_master_index

13) Update the permissions for each of these folders:

sudo chmod -R a+w sitecore_web_index

sudo chmod -R a+w sitecore_master_index

sudo chmod -R a+w sitecore_core_index

sudo chmod -R a+w sitecore_analytics_index

sudo chmod -R a+w social_messages_web
sudo chmod -R a+w social_messages_master
sudo chmod -R a+w sitecore_testing_index
sudo chmod -R a+w sitecore_suggested_test_index
sudo chmod -R a+w sitecore_marketingdefinitions_web_index
sudo chmod -R a+w sitecore_marketingdefinitions_master_index
sudo chmod -R a+w sitecore_marketing_asset_index_web
sudo chmod -R a+w sitecore_marketing_asset_index_master
sudo chmod -R a+w sitecore_list_index
sudo chmod -R a+w sitecore_fxm_web_index
sudo chmod -R a+w sitecore_fxm_master_index

If you are running a later version of Sitecore (e.g. 8.2 Update 1), you will also need to copy across this solrconfig.xml file into each index folder:

https://gist.githubusercontent.com/blacktambourine/79447ccadcd5b898ab8aedf1b63595bb/raw/1927039990d6323f4b7f76a8260cdbfa34400548/solrconfig.xml

Note that this may change from version to version of Sitecore, so lookup the sitecore reference at the bottom of this blog for more info.

13) Open the Solr admin page

(mysitename.cloudapp.azure.com/solr/

) and click on

Core Admin

. Enter the name of an index in the name and instanceDir fields and click

Add Core

. Do this for each index you setup in Step 12.

Please note that in Sitecore 8.2 Update 1, the sitecore_marketingdefinitions_web_index and sitecore_marketingdefinitions_master_index should have a Core name of sitecore_marketingdefinitions_web and sitecore_marketingdefinitions_master respectively.

14) Disable the following config files in your Web App:  

  • Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config
  •      
  • Sitecore.ContentSearch.Lucene.Index.Analytics.config
  •      
  • Sitecore.ContentSearch.Lucene.Index.Core.config
  •      
  • Sitecore.ContentSearch.Lucene.Index.Master.config
  •      
  • Sitecore.ContentSearch.Lucene.Index.Web.config
  •      
  • Sitecore.ContentSearch.Lucene.Indexes.Sharded.Core.config
  •      
  • Sitecore.ContentSearch.Lucene.Indexes.Sharded.Master.config
  •      
  • Sitecore.ContentSearch.Lucene.Indexes.Sharded.Web.config

15) Enable the following config files:    

  • Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config
  •      
  • Sitecore.ContentSearch.Solr.Index.Analytics.config
  •      
  • Sitecore.ContentSearch.Solr.Index.Core.config
  •      
  • Sitecore.ContentSearch.Solr.Index.Master.config
  •      
  • Sitecore.ContentSearch.Solr.Index.Web.config

16)  Change these settings in Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config:

<setting name="ContentSearch.Solr.ServiceBaseAddress" value="http://mysitename.cloudapp.azure.com:80/solr" />

<setting name="ContentSearch.Solr.EnableHttpCache" value="false" />

17) Add Castle.Core and Castle.Windsor references to your dev solution; deploy these DLL’s to your Web App.

18) Edit the markup of your Global.asax to the following and deploy to your Web App:

<%@ Application Language='C#' Inherits="Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorApplication" %>

19) Note: if you are not migrating all Lucene indexes into Solr you will need to leave this config enabled:

Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config

20) Rebuild your indexes in Sitecore Control Panel

21) Ensure that Solr is running as a service and will rerun on restart of the VM:

sudo ./ctlscript.sh start

22) Rebuild the Sitecore indexes. If the indexes don’t build and your Solr logs have the “Can not find: schema.xml [/opt/bitnami/apache-solr/server/solr/sitecore_*_index/conf/schema.xml]“ error message you will need to re-upload the schema.xml to each index and then restart your Azure Web App.


References:

https://sitecore-community.github.io/docs/search/solr/Configuring-Solr-for-use-with-Sitecore-8/

https://blog.horizontalintegration.com/2015/01/21/sitecore-8-solr-configuration-and-setup/

https://doc.sitecore.net/sitecore_experience_platform/80/setting_up__maintaining/search_and_indexing/walkthrough_setting_up_solr