We all remember the pain involved in switching Search Providers from Lucene to Solr.  There were many a tales of woe.  It crushed dreams.  Drinks were had in order to lament. Maybe it wasn’t that bad.  But… Sitecore listened to us!

With Sitecore 9, switching search providers is EASY.  How easy? Check out the setting in your web.config:

<!-- SUPPORTED SEARCH PROVIDERS     
	 Specify the search provider that you want this server to use. The supported search providers are:

	 Lucene
	 Solr
	 Azure

Default value: Lucene
-->
<add key="search:define" value="Solr"/>

Is it really that easy? In a word, “yep”.  Prying open the other search-related configs, we can see some familiar SC9 markup. Here’s the top portion of the Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config file:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
  <sitecore search:require="lucene">
    <contentSearch>

Notice the search:require attribute.  That tells Sitecore to only execute that when the search is defined as Lucene. Opening up the corresponding Solr config file (Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config):

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
  <sitecore search:require="solr">
    <contentSearch>

Long gone are the “An index with the name ‘sitecore_marketing_assets’ already exists” because you forgot to nuke the Lucene index definition config when you swapped to Solr.
[ls_content_block slug=”nineonninefooter”]

Facebooktwitterredditlinkedinmail