sitecore-solr
ASP.NET, CMS

How to configure Solr Core for Sitecore 8.2 Search Index

Apache solr is an open source search platform built upon java library. It’s one of the most popular search platform used by most websites.

Prerequisite

Java (Latest JDK Version).

Installing Solr

Download the Solr binaries from http://lucene.apache.org/solr/ , for Linux/Unix/OSX systems, download the .tgz file. For Windows , download the .zip file. You need to extract the Solr distribution archive to a desired directory.Start solr by using the solr start command by setting path to bin folder of installation from command prompt, Solr will be started on the default port 8983 . We can configure Solr to run on a different port using the following command in the bin folder of installation from command prompt.

solr start -f -p [PortNumber]

Core Creation

A Solr core is an index of the text and fields found in documents, Solr core can be created by duplicating the basic configs in the [SolrFolderPath]\server\solr\configsets. Move the basic configs to [SolrFolderPath]\server\solr, rename the duplicated basic configs, Create core in the solr Admin interface, the name and instance directory should be same as the index name created by duplicating the basic configs.

Core Creation through Solr Admin Interface
Core Creation through Solr Admin Interface

Generate Solr Schema

Generate schema.xml from sitecore interface from indexing manager in control panel, generating the schema from sitecore interface requires a source schema file, Rename the managed schema to schema-orig.xml, enclose the <field> in <fields> tags and <fieldtype> in <types> tags

Generate Solr Schema from the Sitecore Control Panel
Generate Solr Schema from the Sitecore Control Panel

Enabling Sitecore Solr Configs

By default all the solr configs are disabled and lucene serves as the default search provider , to change the default search provider to solr , disable all the lucene configuration files and enable the solr configuration files in App_config/Include folder of your sitecore instance

In the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config change the Service base address of solr

<setting name="ContentSearch.Solr.ServiceBaseAddress" value="http://127.0.0.1:8983/solr" />

where 8983 is the default port of solr and change the content search provider to Solr

<setting name="ContentSearch.Provider" value="Solr" />

Download the solr search support package based on your sitecore version and add the DLLs to the bin folder of the sitecore instance.

Configure An IOC Container

In Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config , change the following processor,depending on the Ioc container you wish to choose among Autofac , Ninject , Unity, StructureMap.

<processor type="Sitecore.ContentSearch.SolrProvider.Pipelines.Loader.InitializeSolrProvider, Sitecore.ContentSearch.SolrProvider"/>

Castle Windsor

<processor type="Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorInitializeSolrProvider, Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration"/>

Autofac

<processor type="Sitecore.ContentSearch.SolrProvider.AutoFacIntegration.AutoFacInitializeSolrProvider, Sitecore.ContentSearch.SolrProvider.AutoFacIntegration"/>

Ninject

<processor type="Sitecore.ContentSearch.SolrProvider.NinjectIntegration.NinjectInitializeSolrProvider, Sitecore.ContentSearch.SolrProvider.NinjectIntegration"/>

StructureMap

<processor type="Sitecore.ContentSearch.SolrProvider.StructureMapIntegration.StructureMapInitializeSolrProvider, Sitecore.ContentSearch.SolrProvider.StructureMapIntegration"/>

Unity

<processor type="Sitecore.ContentSearch.SolrProvider.UnityIntegration.UnityInitializeSolrProvider, Sitecore.ContentSearch.SolrProvider.UnityIntegration"/>

Rebuild Indexes

Rebuild indexes from Indexing manager in sitecore.

Rebuild Sitecore Indexes from Indexing Manager
Rebuild Sitecore Indexes from Indexing Manager

Finally, a quick review of DO’s when configuring Sitecore with Solr

  • – Do check the sitecore version compatibility with solr version at https://kb.sitecore.net/articles/227897
  • For every solr index config enabled, a solr core should be present, core without schema causes errors
  • Ensure index id is same as the name of your core in respective solr index configuration.
  • It is recommended to have a 64-bit java installed, since with 32-bit only 4GB RAM can be utilized to the maximum extent and as the size of indexes grow Java throws an out of memory error.
  • – In solrconfig.xml file, set schemaFactory to ClassicIndexSchemaFactory
    <schemaFactory class="ClassicIndexSchemaFactory" />

     

About The Author

Leave a Reply

*