In an application there are many times we need to use an index to make our application perform as expected. This blog post will show you how to set up an index on the Sitecore side as well as the Solr side.
Solr Configuration Setup
Setting up a core on the Solr side is easy. It should take no more than 5 minutes. Follow these steps and you should be good to go. First let’s assume we are making a new index called someNewIndex. If we want to have a swap index (not required), you’ll want to duplicate these steps but suffix the index name with _swap.
- Stop Tomcat
- Drill down to the Solr folder in your Tomcat directory (my local solr is located here: C:\tomcat\solr)
- Find an existing core, copy that and rename it to your new index to someNewIndex.
- Open the someNewIndex folder and you should see a file named: core.properties. Open this file and set the name value equal to the name of your index: someNewIndex
- Delete the data folder within the someNewIndex folder. This will clear all the data from the index and the folder will be recreated once Solr starts back up.
- Now that we have the structure setup, we need to modify the solr.xml file that lives on the root of the Solr directory. You will see a section called cores, you need to add an entry in here for your new index/core.
- At Collette we have many indexes. We have grouped them into subfolders as you can see in the screenshot below.
- Start Tomcat and open the Solr Web Console to see if we can see our new core and verify the web console is not calling out any errors related to our new core.
Sitecore Configuration Setup
Now that we the Solr configuration complete let’s take a look at the Sitecore side of things. Everything we need lives in the Sitecore.ContentSearch.Solr.config file. If you are not familiar with this file please refer to my blog post that explains each section.
- You will want to create a new config called: Sitecore.ContentSearch.Solr.Index.SomeNewIndex.config. The purpose of this file is to identify to the Sitecore Content Search layer the index/core that you built on the Solr side of things.
- Take a look at the screenshot below. You will want to build a similar structure in your new config. You’ll need to set your index name, your swap core, indexing strategy and root directory.
- Save your changes, log into the Sitecore desktop, and navigate to the control panel click on Indexing Manager. Here you want to make sure your index shows up.
- Rebuild the index to fill the index with data. Once the rebuild is complete you will want to examine the data in the Solr Web Console.
*Keep in mind, if you do not need to use a swap core you can remove the rebuildcore parameter and you will want to change the index type from SwitchOnRebuildSolrSearchIndex to SolrSearchIndex.
As with anything, feel free to reach out if you have any questions.
Thanks and I hope this post was helpful!