Sitecore 8.2 is out! Solr 6.2 is out! Let’s get up running with both!
This is a short and updated version of a previous post on Sitecore and Solr “How to use Solr with Sitecore 8 – the easy way”.
Step 1: Generate the basic Solr schema file from your Sitecore installation
Note: I have created a zip file you can use – so you don’t have to do all these steps really – unless you use another version of Sitecore.
In short – you need to follow these steps if you really want to do this work:
- Download and install Solr 6 (http://lucene.apache.org/solr/downloads.html)
- Copy the directory “basic_configs” to create a Sitecore_configs (I copied \solr-6.2.1\server\solr\configsets\basic_configs to \solr-6.2.1\server\solr\configsets\sitecore_configs)
- Open and edit the managed-schema.xml file by all <fieldTypes> are structured under <types>, and all <field> are structured under <fields>. In short:
<types> <fieldType name="string" class="solr.StrField" ….. …... </types> <fields> <field name="id" type="string" ….. ….. </fields>
- Use the Generate Solr Schema in the Sitecore control panel
- After the schema.xml is generated, delete the managed-schema.xml
- Open the solrconfig.xml and add a ClassicIndexSchemaFactory definition:
- Open the newly generated schema.xml file and add:
<fieldType name="pint" class="solr.TrieIntField" docValues="true" precisionStep="0" positionIncrementGap="0" /> so it looks like this:
Step 2: Prepare and organize you Solr core structure
I like to have a separation between configuration and data. Sitecore 8.2 has not added any new indexes – so I can use the folder structure from my old post. So for each index we need to create a folder for each of our Sitecore indexes: (Note: you don’t have to do this – you can download the files from this post).
To create the first core follow these steps:
- Create a new folder: \solr-6.2.1\server\solr\cores_conf
- Create a new folder: \solr-6.2.1\server\solr\cores_conf\sitecore_analytics_index
- Copy the folder \solr-6.2.1\server\solr\configsets\sitecore_configs\conf to the folder: \solr-6.2.1\server\solr\cores_conf\sitecore_analytics_index
- Create a property file that tells Solr where the configuration files are, and where to place the data files:
- Create a text file in the sitecore_analytics_index folder and name it: core.properties
- Make sure that the file has the following line: dataDir=../../cores_data/sitecore_analytics_index
- Check that Solr locates the core on startup.
- From here on, it’s just a matter of copying and renaming the core we just created. For each core do the following:
- Duplicate the sitecore_analytics_index folder. Rename it to [new-core-name]
- Edit the core.properties in the [new-core-name] folder, change the only line to: dataDir=../../cores_data/[new-core-name]
- Repeat the process until you have following cores created:
- Restart Solr and verify that you have all the cores up running in Solr.
Step 3: Patch the configuration to use Solr for all the indexes instead of Lucene
- Create a folder “zzzSolrIndexes” and place this in App_Config\Include. In this folder copy all the Solr configuration files that ships with Sitecore as .disabled or .example:
- Remove the .example and .disabled from the above files.
- Disable all the currently enabled Lucene indexes by a single patch file:
Create a file in our zzzSolrIndexes folder, and ensure that this patch fill will be executed before all your Solr configurations. Name the patch file: aaaSitecore.ContentSearch.DisableAllLuceneIndexes.config
The content of that file is where we simply remove the Lucene indexes – one by one:
<?xml version="1.0" encoding="utf-8" ?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/"> <sitecore> <contentSearch> <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch"> <indexes hint="list:AddIndex"> <index id="sitecore_analytics_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider"> <patch:delete /> </index> <index id="sitecore_master_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider"> <patch:delete /> </index>
Repeat the lines for all the index ids. You can use the lists of the cores we created in the beginning of this blog. You should end up with disabling 15 indexes.
Note: you can download a copy of these files at the end of the post. Just unzip and place it in your include folder.
Step 4: Install the Solr support packages from Sitecore
- Download the Sitecore support package from Sitecore (Sitecore.Solr.Support 2.0.0 rev. 160726).
There’s support for a number of number of IoC containers. Choose the one that you are comfortable in using, or already uses as part of your project. The packages NO LONGER uses the global.ascx for initiating the Solr provider (nice!).
Copy config file (e.g. Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.IOC.StructureMap.config – remove .example) to the App_Config\Include.
- Copy the needed DLLs that also was part of Solr Support Package. Example for structuremap:
- Structuremap.dll (not part of the Sitecore Solr Support Package)
Step 5: Check that it works!
- Re-index it all
- Go to the Control Panel
- Choose Indexing Manager
- Select All
- Click “Start”
Summary – and downloads
The fast way to get Solr 6 running with Sitecore 8.2. is shown in this post. The fast way:
- Download zzzsolrindexes for Sitecore 8.2 – unzip and place that under App_Config\Include
- Download cores_conf for Solr 6.2 – unzip and place under your Solr 6 installation – under \solr-6.2.1\server\solr
- Download the support Solr package – select your favorite IoC and select the DLL and config that fits with your choice.
- Restart your Solr and go rebuild your Sitecore indexes.
- You are now running on Solr instead of Lucene.