Hi! So you want to create a new Solr index?
It’s a great idea. You’ll be familiar with the big three,
sitecore_core_index, sitecore_master_index and sitecore_web_index, but you don’t have to stop there! You can create individual indexes for certain content types on your site, such as Products. Smaller, more individualised indexes are easier to maintain, troubleshoot, faster to rebuild and can be faster to query.
Not as hard as you’d expect! Let’s create one now.
OK. My Solr is set up and I can access the web UI on https://solr:8983/solr/#/ – what now?
- Find your Solr index folder for the sitecore_master_index. Mine was at
- Copy this whole folder (into the same parent folder) and call it
- Inside the
sitecore_master_products_indexfolder, open up the core.properties file and change the name property to read
- Restart Solr (I use the solr stop and solr start commands – see below)
- Now, go to
https://solr:8983/solr/#/and check out your cores – you will have a new one!
Awesome, it’s there. So I get that we copied the sitecore_master_index and renamed it to
sitecore_master_products_index – and in Solr I can see that it contains thousands of documents already, copied from
sitecore_master_index. How do I clean things up?
Well, good question. We want to delete all of the existing items in this index and start afresh. You can do this via a web browser – just call this URL:
Radical. Everything is deleted. Soo. I want to use this index to only contain certain types of content from Sitecore. How do I configure it properly?
We need to just add a single configuration file to Sitecore. It’s below. It looks mostly like the configuration file for
sitecore_master_index, but we change two important things, (a) which template types we want to include in our index and (b) which field types we want to include in our index. In your real solution, this will take a bit of time to set up, but being selective is the whole point of creating a custom index, and you’ll want to keep it as trim as possible.
Here’s the whole config file, which I’ve called
The two bits you’ll need to replace here are the bits commented as Included Fields and Included Templates:
OK, done. I’ve added my list of templates, and fields here. So, can I reindex now and see my new content?
Absolutely. Go into
Sitecore > Control Panel > Indexing Manager, find your index and rebuild it.
When you’re done, go back to the Solr UI and see your documents! If things didn’t go quite to plan, check in your site
Crawling.log, which will contain any indexing errors.
Well, not quite. You might want to create a
sitecore_web_products_index and use the
Sitecore.ContentSearch.Solr.Index.Web.config configuration file as an example of how to register it in Sitecore. Using Sitecore’s conventions for master and web keep the surprises to a minimum.
Search on, pals!