If you've been working with Sitecore 9+, on Solr, and been using xDB or EXM or even on a Standalone instance and enabled or disabled xDB recently, then it's likely (though not guaranteed) that you've encountered an error message indicating the sitecore_marketingdefitions_master index was not found.
What does the error look like? Glad you asked. Depending on your level of exception gathering, you may not see it until you look in your log files, or you may see that dreadful yellow error screen. In any case, the error message typically resembles the following:
Exception Details: Sitecore.ContentSearch.Exceptions.IndexNotFoundException: Index sitecore_marketingdefinitions_master was not found Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [IndexNotFoundException: Index sitecore_marketingdefinitions_master was not found] Sitecore.ContentSearch.ContentSearchManager.GetIndex(String name) +127
This is an error that can cause some anxiety especially when it shows up after what may have seemed like an innocuous change. It's also an error that can go away if you refresh your browser a few times. However, while that may work, it's not going to stop the error from reoccurring.
How To Fix It?
It turns out, the simplest solution is adding a patch file with the tag <initializeOnAdd>true</initializeOnAdd>
to the <marketingDefinitionSolrIndexConfiguration>
section.
What does that patch file look like exactly? Glad you asked. Below you'll find one we have used recently. Just store it in your App_Config/include directory and your problem should go away. Note that depending on your environment, you may need to make adjustments to the role attribute if you've modified yours accordingly.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:search="http://www.sitecore.net/xmlconfig/search/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="Standalone or ContentDelivery or ContentManagement" search:require="solr">
<marketingDefinitionSearch>
<indexConfigurations>
<marketingDefinitionSolrIndexConfiguration>
<initializeOnAdd patch:before="fieldMap">true</initializeOnAdd>
</marketingDefinitionSolrIndexConfiguration>
</indexConfigurations>
</marketingDefinitionSearch>
</sitecore>
</configuration>
In The End...
While a lot of the out-of-the-blue errors that appear with Sitecore, may seem like mountains to overcome, many of them are easily solvable. Some as simple as with a patch file. We hope this solution finds you well.