Let’s Build a simple country index

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.

  1. Stop Tomcat
  2. Drill down to the Solr folder in your Tomcat directory (my local solr is located here: C:\tomcat\solr)
  3. Find an existing core, copy that and rename it to your new index to someNewIndex.
  4. 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
  5. 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.
  6. 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.
    1. At Collette we have many indexes. We have grouped them into subfolders as you can see in the screenshot below.
  7. 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.

solrCores

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.

sitecoreConfig2

As with anything, feel free to reach out if you have any questions.
Thanks and I hope this post was helpful!
Tim

This entry was posted in Solr and tagged on by .

About tbraga1983

Digital Professional, Sitecore MVP, started working with Sitecore back in 2008 when I worked for Velir. I joined Collette in 2013 to lead up their new website from the ground up. We started fresh on Sitecore 7, Solr, EXM and xDB.

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