Installation and Configuration of Solr for Sitecore 8

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.

solrinstance

A tool is also automatically installed during the installation process. You can access this tool to manage the server.bitnamitool

solrinstance1

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:

config 1

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”/>

Specifically,

Make the following changes in the default schema.xml file shipped with Solr:

  1. Enclose all <field> and <dynamicField> elements in the <fields> tag.
  2. 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.

config 2

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).

Sitecore Schema Gen

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

schema

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)

solrinstance2

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.

Disable:

    • Sitecore.ContentSearch.Lucene.Index.Analytics.config.disabled

Enable:

    • Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config
    • Sitecore.ContentSearch.Solr.Index.Analytics.config

Step 5: Change next settings in Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config:

  • <setting name=”ContentSearch.Solr.ServiceBaseAddress” value=” http://xxxx.com:8983/solr&#8221; />- 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”.

<param desc=”group”>experience</param>

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.

solrinstance3

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:

http://xxxx.com/solr/sitecore_analytics_index/select?q=*&rows=100

References

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

(2) http://www.sequence.co.uk/blog/sitecore-8-and-solr/

(3) https://sitecore-community.github.io/docs/search/solr/installing-solr-using-the-bitnami-apache-solr-stack/

(4) https://sitecore-community.github.io/docs/

 

This entry was posted in Information Technology, Sitecore, Solr and tagged , , , , , , . Bookmark the permalink.

8 Responses to Installation and Configuration of Solr for Sitecore 8

  1. Branko Markovic says:

    I did everything step by step with no problem.
    After step 6 in the “Configuration of Sitecore 8 to work with Solr” I have an Sitecore error:
    Connection error to search provider [Solr] : Unable to connect to [http://127.0.0.1:81/solr], Core: [sitecore_analytics_index]

    When I call link “http://127.0.0.1:81/solr”, direct in the browser, they ask me for credentials and after adding username and password that I created during installation of “Solr”, I’m redirected properly to the “Solr”.

    Any idea about error in the Sitecore?
    Is it something related to the credentials that I had to add during installation of “bitnami-solr-5.5.0-1-windows-installer.exe”?

  2. Anumoy Sutradhar says:

    Error with SOLR and Site Core 8.1 integration.

    Steps I did on the server:
    Install Sitecore 8.1
    Installed SOLR 6.0.0 (Also tried 5.5.0, did not change anything) and followed the blog: http://www.sequence.co.uk/blog/sitecore-8-and-solr/
    and
    https://sitecore-community.github.io/docs/search/solr/Configuring-Solr-for-use-with-Sitecore-8/

    After I generated the schema.xml according to the blogpost I always get an error when I try to build search index:

    Job started: Index_Update_IndexName=sitecore_core_index|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> SolrNet.Exceptions.SolrConnectionException:

    4002org.apache.solr.common.SolrExceptionorg.apache.solr.common.SolrExceptionundefined field _indexname400

    Hope you all can help me with the issue.

    Thanks in advance.

    Anumoy Sutradhar

    • wenronglexin says:

      If you have Solr worked with Sitecore 8.0, then there is no change or upgrade need to be done for Sitecore 8.1. Recently we just upgrade from Sitecore 8.0 to 8.1 rev. 151217. There was no change required for Solr search.

  3. Jonas says:

    I have followed your guide to install and configure Solr, but when I go to Indexing Manager and select one or more indexes to be rebuilt, then nothing happens. It says ‘Rebuilding…’, but the selected indexes never change from status ‘Queued’. There is nothing in the Sitecore logs to indicate any problem.

    Do you have any ideas on what might be wrong and what I could do to fix it?

    • wenronglexin says:

      First, my post is about a hybrid approach to use Solr to index analytic data only, other indexes are still with Lucene. You won’t see sitecore_analytics_index in control panel. It is crawled by Sitecore on a schedule base.
      if you want to use Solr to index everything, you may need to enable all Solr index configuration files and disable all Lucene index files. Also in Solr, you need to create cores for each index, just same as I did sitecore_analytics_index. To verify if the indexes work or not, you can go to Solr dashboard to check each core and make query. Good luck!

  4. Amanda says:

    Thanks for the instructions! After following these I was getting the server error: Field type ‘alphaOnlySort’ not found. It turns out I had to add that fieldType in to my schema.xml. I find it odd that that wasn’t already in that file, and more odd that no one else seems to report having the same issue. Did I miss a step somewhere that would have had that included?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s