0

Configuring Solr search with Sitecore 8

17/02/2015 – Update

  • Sitecore 8.0 rev. 150121 (Update 1) comes with a fixed FXM Solr config and it is no longer required to replace it.
  • ID’s of the indexes in the FXM Solr config in Update 1 have changed to be in line with the other index naming conventions. I’ve reflected this change in the example patch configuration in the post.
    • sitecore_fxm_domains_master >> sitecore_fxm_master_index
    • sitecore_fxm_domains_web >> sitecore_fxm_web_index

As this post is intended to point out some of the details with regards to setting up Solr on Sitecore 8 it won’t be delving into the general setup. If you haven’t used Solr with Sitecore 7+ then I highly recommend reading Dan Solovay’s (@DanSolovayblog post on it.

For the most part getting Solr running on Sitecore 8 is close to as it was with Sitecore 7, there are few more configuration files to change and a couple “gotchas”/issues.

Configuration Files

If you want everything switched over to Solr then the below is a complete list of the configuration files that need to be disabled/enabled. You can run the site in a kind of “dual-mode” whereby some features can still use Lucene. Before you go doing some mass name changing there are some notes to be mentioned first.

  • FXM – there’s a known issue with the Solr configuration file, you can get the fixed file from here: https://kb.sitecore.net/articles/683462.
  • Marketing Assets – it appears the Chinese language is missing in the Solr schema file, see here for more information.

Disable

\App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Analytics.config.disabled
\App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Core.config.disabled
\App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Master.config.disabled
\App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Web.config.disabled
\App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.Index.Master.config.disabled
\App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.Index.Web.config.disabled
\App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.IndexConfiguration.config.disabled
\App_Config\Include\ContentTesting\Sitecore.ContentTesting.Lucene.IndexConfiguration.config.disabled
\App_Config\Include\ContentTesting\FXM\Sitecore.FXM.Lucene.Index.DomainsSearch.config.disabled
\App_Config\Include\ListManagement\Sitecore.ListManagement.Lucene.Index.List.config.disabled
\App_Config\Include\ListManagement\Sitecore.ListManagement.Lucene.IndexConfiguration.config.disabled
\App_Config\Include\Social\Sitecore.Social.Lucene.Index.Master.config.disabled
\App_Config\Include\Social\Sitecore.Social.Lucene.Index.Web.config.disabled
\App_Config\Include\Social\Sitecore.Social.Lucene.IndexConfiguration.config.disabled

Enable

\App_Config\Include\Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config
\App_Config\Include\Sitecore.ContentSearch.Solr.Index.Analytics.config
\App_Config\Include\Sitecore.ContentSearch.Solr.Index.Core.config
\App_Config\Include\Sitecore.ContentSearch.Solr.Index.Master.config
\App_Config\Include\Sitecore.ContentSearch.Solr.Index.Web.config
\App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.Index.Master.config
\App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.Index.Web.config
\App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.IndexConfiguration.config
\App_Config\Include\ContentTesting\Sitecore.ContentTesting.Solr.IndexConfiguration.config
\App_Config\Include\ContentTesting\FXM\Sitecore.FXM.Solr.Index.DomainsSearch.config
\App_Config\Include\ListManagement\Sitecore.ListManagement.Solr.Index.List.config
\App_Config\Include\ListManagement\Sitecore.ListManagement.Solr.IndexConfiguration.config
\App_Config\Include\Social\Sitecore.Social.Solr.Index.Master.config
\App_Config\Include\Social\Sitecore.Social.Solr.Index.Web.config
\App_Config\Include\Social\Sitecore.Social.Solr.IndexConfiguration.config

Patching

A change has been made to the “core” parameter for each index. Previously they had been set to “itembuckets” but they are now set to “$(id)”, there are some exceptions (e.g. FXM). This means that by default Sitecore will look for a core based on the ID. If you want continue using a single core name then below is an example patch configuration you can use.

A really important “gotcha” with the patching, and it’s an oldy but a goody, is you must make sure your configuration file is patched last. This has generally been the case in Sitecore anyway but it’s even more so now. A lot of the configuration files mentioned above reside in sub-folders of the App_Config/Include folder. Your best option currently is to have all you configuration files (or folder structure) reside in something like App_Config/Include/UserDefined. With the way the current default folder structure is this will ensure you configuration files are run last. That is until Sitecore add a folder in that comes after “UserDefined” :)! If you want to be super safe you could just name it “zzzzz”, weird though.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
	<Sitecore>
		<contentSearch>
			<configuration>
				<indexes hint="list:AddIndex">
					<index id="sitecore_master_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_web_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_core_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_analytics_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_testing_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_suggested_test_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_fxm_master_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_fxm_web_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_list_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="social_messages_master" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="social_messages_web" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_marketing_asset_index_master" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
					<index id="sitecore_marketing_asset_index_web" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
						<param desc="core">"Your Core Name Here"</param>
					</index>
				</indexes>
			</configuration>
		</contentSearch>
		<settings>
			<!--<setting name="ContentSearch.Solr.ServiceBaseAddress">
				<patch:attribute name="value">http://localhost:8000/solr</patch:attribute>
			</setting>-->
		</settings>
	</sitecore>
</configuration>

Issues

Error when rebuilding the “sitecore_marketing_asset_index_master”

Example:

ERROR: [doc=sitecore://master/{715c5bb4-3584-4510-8815-c42f88b1034e}?lang=zh-cn&amp;amp;ver=1] unknown field 'height_t_zh'

This is caused because the schema that is generated is missing the dynamic field for the Chinese language. Something like the below should exist in the schema but it doesn’t, this is an example please don’t add it :).

<schema name="example" version="1.5">
	<fields>
		<dynamicField name="*_t_zh" type="text_zh" indexed="true" stored="true" />
	</fields>
	<types>
		<!-- Chinese -->
		<fieldType name="text_zh" class="solr.TextField" positionIncrementGap="100">
			<analyzer>
				<tokenizer class="solr.StandardTokenizerFactory" />
				<filter class="solr.TurkishLowerCaseFilterFactory" />
				<filter class="solr.StopFilterFactory" ignoreCase="false" words="lang/stopwords_zh.txt" />
				<filter class="solr.SnowballPorterFilterFactory" language="Chinese" />
			</analyzer>
		</fieldType>
	</types>
</schema>

Solution: Continue to use Lucene for these indexes.

Jason Bert