Today I am going to tell you about how to configure the Solr instead of lucene.
Here we using solr via Tomacat server. So these points I need to cover.
- Install/Configure the tomcat
- Install/Configure solr
- Configure for sitecore
- 1. Install Java jre from below URL:
- Install Windows Service Installer for apache tomcat from below URL:
Note: Please select host manager option ticked and default location for tomcat is:
C:\Program Files\Apache Software Foundation\Tomcat 8.0
The default port used by Tomcat is 8080 (used to be 8983) but you may elect to use some other port. Don’t choose port 80.
Note: If you want run more then one tomcat on on system then use different connector port and shutdown port.
Eg: connector port: 8983, 8038, 8039 etc.
Shutdown port: 8005, 8025 etc.
- Type configure tomcat and select automatic mode.
- you can also select for alias name for tomacat by update in conf/server.xml in tomcat directory.
Download Solr 4.10.3 from http://lucene.apache.org/solr/downloads.html. Since we are installing on a Windows machine, you will want to get the .zip file version of the download.
Note: Archives for all past versions of Solr are available at the Apache archives.
- Extract the contents of the .zip to a temporary location of your choice.
- Find the \dist folder in the extracted solr-4.10.3 directory. Rename the solr-4.10.3.war to solr.war and copy the file to the Tomcat’s \webapps folder. The path in my environment was C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps.
- Create an empty Solr home folder. This will be the permanent place of residence on your machine for your Solr instance. For example, D:\solr is where I put my Solr instance.
- Find the \example\solr folder in the extracted solr-4.10.3 directory. Copy the contents of \example\solr to the empty Solr home folder you just created in step 4.
- Find the \example\lib\ext folder in the extracted solr-4.10.3 directory. Copy the contents of \example\lib\ext to Tomcat’s \lib folder. The path in my environment was C:\Program Files\Apache Software Foundation\Tomcat 8.0\lib.
- Set the home directory for Solr in Tomcat. This is done by adding a new Java option with the Monitor Tomcat program. In my case, the option was -Dsolr.solr.home=D:\solr
- Stop/start Tomcat and try browsing to your Solr instance. For example,http://tomcat:8983/solr.
Configure for Sitecore:
- Stop the Tomcat service.
- Go to the root of your Solr instance, in my case, D:\solr. We need to modify the “collection1” directory to serve as one of the cores (folders with config files and index data) required by Sitecore.
- Rename the folder to “sitecore_analytics_index”
- Inside the folder you will find a file called “core.properties” which you may edit with a text editor. You need to change the “name” value to the name of your core. For example, when I create the “sitecore_analytics_index” core, then I will edit the “core.properties” file to have the value name=sitecore_analytics_index
- Start the Tomcat service and visit the Solr administration page. You may need to reload your browser page if it was already up. Click on the “Core Admin” menu item. If you modified the old “collection1” core correctly you should now see a sitecore_analytics_index core.
- Stop the Tomcat service. Now we need to fix the schema of our “sitecore_analytics_index” core, otherwise Sitecore cannot parse the xml correctly. Edit the file at \sitecore_analytics_index\conf\schema.xml according to Sitecore’s knowledge base article: https://kb.sitecore.net/articles/227897. Don’t forget to define the field type for pint since we are using a version of Solr later than 4.9! Start Tomcat and reload the Core Admin page.
- Next we must generate a new, Sitecore-specific schema. Sitecore provides a tool for this. Navigate to the Control Panel of your Sitecore instance. Look for the “Generate the Solr Schema.xml file” link and click it. Provide a path for the source and target files (they can’t be the same file.) Once you have generated your new schema, replace the old schema with it. Restart the Tomcat service and make sure the core loads correctly.
- A vanilla install of Sitecore 8 update 2 requires 13 cores to work correctly. So far we have one, but don’t despair, now that we have a generated a schema this process is much easier. Essentially, we are going to use our sitecore_analytics_index core as a template to create the others. To do this:
- Copy the sitecore_analytics_index folder.
- Repeat steps 2a and 2b for each copy.
- When you are done, your Solr home folder should contain the following cores
- If you have done everything correctly you should be able to restart Tomcat and see all the cores listed above on the Core Admin page.
- Update (3-7-2015): I decided to create a PowerShell shortcutfor this step. Save yourself time!
Still with me? Hang in there, we are halfway home! Next, we must tell Sitecore to start using Solr instead of Lucene. This is done by appending or removing “disabled” as an extension of a configuration file’s name.
- Config files to DISABLE:
\App_Config\Include\Sitecore.ContentSearch.Lucene.Indexes.Sharded.Core.config.example (left as is)
\App_Config\Include\Sitecore.ContentSearch.Lucene.Indexes.Sharded.Master.config.example (left as is)
\App_Config\Include\Sitecore.ContentSearch.Lucene.Indexes.Sharded.Web.config.example (left as is)
- Config files to ENABLE:
- So I know that last step was pretty tedious, but if you’ve made it this far then the rest will be easier. Download the Solr Support Packagefrom Sitecore and extract the contents of the zip file.
- Copy the following DLLs from the Solr Support Package into the \bin folder of your Sitecore Instance [N.B.: Castle Windsor is my Inversion of Control preference as Glass also uses it. Aside from Castle Windsor, Sitecore supports AutoFac, Ninject, StructureMap, and Unity.]:
- Download the Nuget package for Castle Windsor. Unzip the package by renaming the extension from .nupkg to .zip and extracting its contents. Copy the Castle.Windsor.dll from \lib\net40-client to the \bin folder of your Sitecore instance.
- Repeat step 10 for the CoreNuget package. Copy the Castle.Core.dll from \lib\net40-client to the \bin folder of your Sitecore instance.
- Since we are going to use IoC, we need to make our Sitecore instance aware of it by replacing the Application directive in the global.asax file with the following:
<%@Application Language=’C#’ Inherits=”Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorApplication” %>
- In order for Sitecore to talk to Solr, we need to give it a URL. This setting is maintained in the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file (remember, your address may differ from mine):
<setting name=”ContentSearch.Solr.ServiceBaseAddress” value=”http://tomcat:8983/solr” />
- When you browse to your Sitecore site you won’t encounter any yellow screens of death. If you see a YSOD complaining about “Connection error to search provider [Solr] : Unable to connect to [http://tomcat:8983/solr]” then you are likely either missing a core or made typo when creating one. Assuming you are error free, the final step is to re-index. Go to the Control Panel and look for the “Indexing manager” link. Select all indexes and click the “Rebuild” button.
Note: Might be you face conflict in Castle.core and Castle.windsor dll because there different-2 version used by solr and glassmapper so you need to update the assembly binding in web.config for overcome that issue as below:
<assemblyIdentity name=”Castle.Windsor” publicKeyToken=”407dd0808d44fbdc” culture=”neutral” />
<bindingRedirect oldVersion=”22.214.171.124-126.96.36.199″ newVersion=”188.8.131.52″ />
<assemblyIdentity name=”Castle.Core” publicKeyToken=”407dd0808d44fbdc” culture=”neutral” />
<bindingRedirect oldVersion=”184.108.40.206-220.127.116.11″ newVersion=”18.104.22.168″ />