- Core Creation
- XML Schema – Generation
- Sitecore’s Solr DLLS – Addition
- Edit Global asax
- Rebuild Indexes
- Java must be already installed for running Solr.
- Get Sitecore 8 (update 4) installed.
- Please download the Solr support package from SDN by using below link: https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform/8_0/Sitecore_Experience_Platform_80_Update4.aspx
- Download Bitnami installer from https://bitnami.com/stack/solr/installer .
We can choose out from different approaches for installing Solr viz.
1. By using Bitnami
2. By following the Solr instructions guide (without using Bitnami) and
3. I recently came across this third option through a blog post by Vasiliy Fomichev (https://hub.docker.com/r/vasiliyfomichev/solr-for-sitecore/ )
Well, here in this blog post, we are going to sail through the first approach – the Bitnami way. Let’s start with the Bitnami Apache Solr Stack. This installer facilitates the installation as well as configuration of solr in many ways and thus makes it pretty easy even for a naïve Sitecore technical to get it done.
To start with, double-click on the installer. The installation process will take you through a couple of dialog boxes. The below shown dialog box is the first one to appear:
We will click Next. The default installation path is C:\Bitnami\solr-5.2.1-1, which can be altered by you as per your wish or requirement.
Now, when we click next, we will be prompted a Screen to provide the port for Apache to run on. Here I would say that if you have chosen to set up Solr for development or if you are installing it locally, please change the default port to anything else, other than 80 (as it is used by IIS). Here, in my case, I have used port 8888.
Please click Next. Once the Bitnami installation has been Complete, check the “Launch Bitnami Apache Solr Stack now?” Check box and click Finish.
Now, you will view a page opened up in your browser, similar to the one shown below:
Now, we will click on the “Access Bitnami Apache Solr” link which will navigate us to Solr dashboard as shown below:
Here, the installation part is complete. Yes, it is… indeed, in just a few simple steps. Now let’s proceed to the configuration of Solr with Sitecore.
- Here, we will use the default SOLR configuration. So, we will copy “basic_configs” folder from the path “C:\Bitnami\solr-5.2.1-1\apache-solr\solr\configsets\” and paste it at the path “C:\Bitnami\solr-5.2.1-1\apache-solr\solr\”. Now we will rename the basic_configs folder to “sitecore_web_index”. Please refer the screenshot below:
- Next step is to create core through Solr Core Admin Interface, as depicted through the screenshot below:
XML Schema – Generation
- Now, please enclose all <field> and <dynamicField> elements in the <fields> tag.
- Enclose all <fieldType> elements in the <types> tag.
- Build Solr Schema Wizard to add the Sitecore specific configuration:
- First, define the fields to index. This is defined in the “schema.xml” file at C:\Bitnami\solr-5.2.1-1\apache-solr\solr\sitecore_web_index\conf.
- Rename this file to “schema_orig.xml”.
- Generate a new Schema.xml file: Now, we require a new schema.xml file to be generated, so please go to your Sitecore instance:
In the Sitecore Desktop, go to the Control Panel:
- In indexing section, you will see “Generate the Solr Schema.xml file” option. Click on that.
Now, here you need to provide the source and target file to proceed.
- In source, type in/paste the full path for “schema_orig.xml”.
- In destination, type in/paste full path for the new “schema.xml”.
- Then click on Generate.
- Once the file is generated, please don’t forget to verify the new schema.xml for the below mentioned contents:
It should contain fields such as: “_ content ” and “_datasource.
<field name=”_ content” type=”string” indexed=”true” stored=”true” required=”true” />
<field name=”_ datasource” type=”text_general” indexed=”true” stored=”true” />
- Now, Reload Solr Core. There are chances that you may encounter errors. For example:
“Unknown fieldType ‘text_es’ specified on field *_t_es“
Don’t worry. We are well prepared with the solution too. To resolve this, we just need to replace “text_*” with “text_general”. Property “type” should be replaced in all such lines to “text_general”. We have done this to resolve the errors from our project which is a sort of test project. But, while working on live projects, we must add – definitions of appropriate language-specific field types (for example “text_es”). So, now the dynami fields in your schema file will change from:
<dynamicField name=”*_t_es” type=”text_es” indexed=”true” stored=”true” />
<dynamicField name=”*_t_es” type=”text_general” indexed=”true” stored=”true” />
- Field type should be defined in the following way:
- <fieldType name=”pint” class=”solr.TrieIntField”/>
- Now go to the SOLR console, select “Core Admin” on the left, and then click on”Reload” on the top which will load the schema changes.
Please Note: The name of the core does not have to be sitecore_web_index. If a different name is given, please ensure that you update the index references in the file Sitecore.ContentSearch.Solr.Index.Web.config.
Sitecore’s Solr DLLS – Addition
- Although, in this walkthrough we are using Castle Windsor, but AutoFac, Ninject, StructureMap and Unity are also, each with their own DLLS). For Castle Windsor, we need to copy the following files over to the project bin directory:
- It is also necessary to add Castle.Core and Castle.Windsor. We can create a solution and use NuGet, or you can pull them directly from the Nuget site, using https://www.nuget.org/api/v2/package/castle.windsor/3.1.0 and https://Hitting these URLs on Chrome automatically downloads a .nupkg object, nuget.org/api/v2/package/castle.core/3.1.0 which you can rename to a zip archive. Both archives contain a “lib\net40-client” path. Copy Castle.Windsor.dll and Castle.Core.dll from lib\net40-client of each package to the website bin directory.
- Change Sitecore’s configuration to use the new index. To do so, perform the below listed three steps.
- First, let’s enable solr config files from the App_Config/Include directory by removing the suffix “.disables” from the file name. For Example:
- Disable all lucene config files from the App_Config/Include directory by adding “.disabled” as a suffix in the file name. For example:
- Now, open “Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config” file and change the default port 8983 to port you have used. In my case it is 8888. So, after adding the port number, it will look as shown below:
<setting name=”ContentSearch.Solr.ServiceBaseAddress” value=”http://localhost:8888/solr” />
Now, wire in the inversion of Control logic by editing the Global.asax “Application” directive to read. This can be achieved by adding the snippet mentioned below:
<%@Application Language=’C#’ Inherits=”Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorApplication”%>
In this document we have covered the creation of web index. Similarly, we can create the other indexes too. Now, final step is to Go to Control Panel\Indexing\Indexing Manager, and rebuild the Core, Master, and Web Indexes. Now, your search must fetch the desired results.