Sitecore 8 Solr Configuration and Setup

Task:  Configuring Sitecore 8 to use Solr for search

Versions:

Sitecore 8, Initial Release (rev 140922)

Apache Solr 4.10.3

Apache Tomcat 8.0.15

Preparation:

Setup or have access to a Solr Search Server (in this case on an Apache Tomcat)

Sitecore 8 instance

Attachments:   Sitecore 8 App_Config files for Solr,  Solr Directory zip file of all cores needed

I followed the documentation in Scaling Guide for Sitecore 7.5, Chapter 3:  Extending Scalability with Solr to configure Sitecore 8 to use Solr for search instead of Lucene:

http://sdn.sitecore.net/upload/sitecore7/75/sitecore_search_scaling%20guide_sc75-usletter.pdf

 In preparing Solr to work with Sitecore, Solr cores are needed for each Sitecore index configured.  To do that, we need to have a schema.xml file.

One of the first challenges was in creating the schema.xml needed to pass through the Sitecore wizard found in Sitecore 8 / Control Panel / Generate the Solr Schema.xml

 Sitecore8SolrSchemaWizard

There is a Schema.xml change required for Solr 4.8 or above which is described in the article with a work- around

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

Once I had a schema.xml needed to create the Solr cores (instead of the “itembuckets” core described in section “3.2.2 Creating a Solr Core” of the scaling guide), the following configuration files require these Solr cores (special thanks to Tamara Perevyazko at Sitecore Support for detailing this and helping me figure out that the error of null reference is what you get when a configured Sitecore search index is missing the Solr core).

             Sitecore Solr configuration files and Solr cores needed:

  1. sitecore_analytics_index: Sitecore.ContentSearch.Solr.Index.Analytics.config.
  2. sitecore_core_index: Sitecore.ContentSearch.Solr.Index.Core.config.
  3. sitecore_master_index: Sitecore.ContentSearch.Solr.Index.Master.config.
  4. sitecore_web_index: Sitecore.ContentSearch.Solr.Index.Web.config.
  5. sitecore_marketing_asset_index_master (“marketingdefinitions” core) -Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.Index.Master.config.
  6. sitecore_marketing_asset_index_web (“marketingdefinitions” core) – Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.Index.Web.config.
  7. sitecore_testing_index: Sitecore.ContentTesting.Solr.IndexConfiguration.config.
  8. sitecore_suggested_test_index: Sitecore.ContentTesting.Solr.IndexConfiguration.config.
  9. sitecore_fxm_domains_master (“fxm” core): Sitecore.FXM.Solr.Index.DomainsSearch.Fix428499.config.
  10. sitecore_fxm_domains_web (“fxm” core): Sitecore.FXM.Solr.Index.DomainsSearch.Fix428499.config.
  11. sitecore_list_index: Sitecore.ListManagement.Solr.Index.List.config.
  12. social_messages_master: Sitecore.Social.Solr.Index.Master.config.
  13. social_messages_web: Sitecore.Social.Solr.Index.Web.config.

Note that typically a core is named the (id), but not in the case of “fxm”, and “marketingdefinitions”) ..

For example in “Sitecore.ContentSearch.Solr.Index.Analytics.config”, the index id is “sitecore_analytics_index” and the core is the same ($(id)).

SitecoreSolrConfigCore

You’ll see this error if a Solr core is missing that is configured in Sitecore:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] SolrNet.Schema.SolrSchemaParser.Parse(XDocument solrSchemaXml) +425 SolrNet.Impl.SolrBasicServer`1.GetSchema() +207 Sitecore.ContentSearch.SolrProvider.SolrSearchIndex.Initialize() +1125 Sitecore.ContentSearch.SolrProvider.SolrContentSearchManager.Initialize() +168 Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorSolrStartUp.Initialize() +757 [HttpException (0x80004005): Object reference not set to an instance of an object.]

I was getting the error below from App_Config\Include\FXM\Sitecore.FXM.Solr.Index.DomainsSearch.config

Server Error in ‘/’ Application.

Could not find property ‘typeMatches’ on object of type: Sitecore.ContentSearch.SolrProvider.SolrFieldMap

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Could not find property ‘typeMatches’ on object of type: Sitecore.ContentSearch.SolrProvider.SolrFieldMap

This article has the work-around

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

Just a quick tip if you want to configure a Solr instance on Apache Tomcat per Sitecore instance, you can set the solr/home <env-entry> in the web.xml file:

C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.15\webapps\solrLaunchSitecore8\WEB-INF\web.xml

<!– Sitecore customization for LaunchSitecore8 to have a solr directory home specified here –>

<env-entry>

<env-entry-name>solr/home</env-entry-name>

<env-entry-value>C:\SolrLaunchSitecore8</env-entry-value>

<env-entry-type>java.lang.String</env-entry-type>

</env-entry>

Attachments

Example Sitecore App_Config/include Solr configuration files

Example Solr directory with all cores

               Screenshot of the Solr Directory and Solr Admin “Cores” list

SolrCoreFiles SolrCoresInAdmin

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: