The installation and configuration of the Solr Provider for Sitecore 8 is not yet documented in Sitecore SDN. With help from Sitecore’s support team, I got everything ironed out. This document describes the installation of Solr and how to configure Solr and Sitecore 8 to allow both parties to work together.
Installation of Solr
Note: this Solr is not directly downloaded from Apache Solr. It is a packaged Solr via Bitnami (https://bitnami.com/stack/solr). This way made the installation much simpler.
I downloaded the latest version of the package (bitnami-solr-5.2.1-1-windows-installer). Install it by double-clicking this installer and let it install by itself. You can select which folder to install Solr.
A tool is also automatically installed during the installation process. You can access this tool to manage the server.
Configuration of Solr
Step 1: To save time, create a custom SOLR configset by copying, pasting and renaming the basic_configs folder (found, for instance, in C:\Bitnami\solr-5.2.1-0\apache-solr\solr\configsets) to create a new one named sitecore_configs like this:
Step 2: Perform the steps described in this KB article for “schema.xml” in sitecore_configs folder. NOTE: For SOLR 5.x “pint” fieldType definition should look like this: <fieldType name=”pint” class=”solr.TrieIntField”/>
Make the following changes in the default schema.xml file shipped with Solr:
- Enclose all <field> and <dynamicField> elements in the <fields> tag.
- Enclose all <fieldType> elements in the <types> tag.
Step 3: Copy the sitecore_configs (C:\Bitnami\solr-5.2.1-1\apache-solr\solr\configsets\sitecore_configs) folder and paste it in C:\Bitnami\solr-5.2.1-1\apache-solr\solr. Rename it to the index you are setting up: sitecore_analytics_index.
Step 4: Pass the schema.xml file from C:\Bitnami\solr-5.2.1-1\apache-solr\solr\sitecore_analytics_index\conf to the “Sitecore SOLR Schema Generator” (Control Panel > Indexing > Generate the SOLR Schema.xml file).
NOTE: This step needs to be executed in SiteCore 8 server. You should be able to use the same file for both source and target but if for some reason you have errors then copy schema.xml to schema-orig.xml and use that as your source).
After you get the modified version of the schema.xml, you need to do two things:
Add a fieldType definition to schema.xml
<fieldType name=”pint” class=”solr.TrieIntField”/>
Then, manually modify the following content further. Basically, you need to replace all type properties to be text_general, at least “*_t_en”.
<dynamicField name=”*_t_en” type=”text_en” indexed=”true” stored=”true” />
After you modify it, it will be as follow:
<dynamicField name=”*_t_en” type=”text_general” indexed=”true” stored=”true” />
Step 5: Put the final schema.xml to the configuration folder of the Solr core
Step 6: Navigate to the SOLR admin page or by pressing “Go to Application” in Bitnami tool.
Step 7: go to “core admin”, fill name and instance dir with the name of the index being added (sitecore_analytics_index)
Configuration of Sitecore 8 to work with Solr
Step 1: Download SOLR Support Package from your update of Sitecore 8 . Unpack the package and copy all dlls from bin folder to your Sitecore bin folder
Step 2: If you prefer Unity IoC and don’t have the Microsoft.Practices.Unity.dll in your bin folder, download and install Unity and the needed dll will be in C:\Program Files (x86)\Microsoft Unity Application Block 2.1\Bin.
Step 3: If you prefer Castle Windsor IoC, ensure that you have Castle.Core and Castle.windsor added to your solution. Two ways to do this include Nuget (probably the simplest) or dropping the assemblies in the bin folder directly.
Step 4: Since we are setting dual-mode of search index, that means the analytics index using Solr and rest of indexes are still with Lucene. In the App_Config/Include folder ensure that the following files have been disabled or enabled depending on their purpose.
Step 5: Change next settings in Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config:
- <setting name=”ContentSearch.Solr.ServiceBaseAddress” value=” http://xxxx.com:8983/solr” />- replace it with actual Solr service link and set port accordingly
- <setting name=”ContentSearch.Solr.EnableHttpCache” value=”false” />- set to false
Step 6: Now you need to convert the application to use Castle.WindsorApplication or UnityIntegration.UnityApplication in the Global.asax. Do this by editing the Global.asax file as follows:
Unity: <%@Application Language=’C#’ Inherits=”Sitecore.ContentSearch.SolrProvider.UnityIntegration.UnityApplication” %>
Castle Windsor: <%@ Application Language=’C#’ Inherits=”Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorApplication” %>
NOTE: If you get an index has no configuration exception after starting the site, check your config patch files for Lucene indexes that are missing the <configuration /> element. When you enable SOLR it becomes the default provider and that causes this exception on existing Lucene indexes that don’t have the provider explicitly configured.
Build the Solr Search Index
Log into Sitecore again and within Control Panel, select Indexing Manager. Click Select All and then click Rebuild…
If all goes well your Solr core will be populated with all the data needed by Sitecore and you can start work on your Solr powered Sitecore 8 application. From the Sitecore Index Manager, there is no index “sitecore_analytics_index” listed as the parameter “Group” setting in file “Sitecore.ContentSearch.Lucene.Index.Analytics.config”.
When it is commented out, index “sitecore_analytics_index” will show up and can be generated from Sitecore control panel. But index “sitecore_analytics_index” is normally generated by crawler.
Verify it works
To check if anything is getting into your index, make some completed visits to the website (followed by session end) and run this query in the browser: