Sitecore Content Search – Creating a Custom DefaultIndexConfiguration

If you are seeing the following Exception when accessing the Index Manager in Sitecore it is likely you have errors within your Index configuration files.

Could not create instance of type: Sitecore.ContentSearch.LuceneProvider.Analyzers.DefaultPerFieldAnalyzer. No matching constructor was found.

The Source

The likely source of the issue is that a custom DefaultIndexConfiguration config file in the /App_Config/Includes/ folder is erroneous.

When creating the custom DefaultIndexConfiguration the likely developer copied the entire content of the Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config file similarly to how you create a custom ContentSearch Index. However only a small subset of the DefaultIndexConfiguration.config is needed to create a custom one.

To identify which of your custom IndexConfigurations are causing the issue, besides opening and viewing the xml, remove them all from the Includes folder and add each one until the Index Manager throws the exception.

The Solution – Create a Custom DefaultIndexConfiguration file

Your custom IndexConfiguration file only need a few of the lines from the out-of-the-box Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config or Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config, depending if you are using Lucene or Solr, to work. Below I have example of the minimum required to get your custom one working. This works for both Lucene and Solr for this example I am using Lucene.

<configuration xmlns:patch="">
<!– Name this XML node the name index configuration you are creating –>
<wildCards type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
<!– Add all required configuration – these can be customised to meet the need –>
<analyzer ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/analyzer" />
<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="_uniqueid" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String"
settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
<analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
<fieldReaders ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/fieldReaders"/>
<indexFieldStorageValueFormatter ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/indexFieldStorageValueFormatter"/>
<indexDocumentPropertyMapper ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/indexDocumentPropertyMapper"/>
<!– Add any Custom Configuration you require –>
<!– Example – I've added the templates I only want indexed
via the IncludeTemplate config. You don't have to include this. –>
<include hint="list:IncludeTemplate">

You can swap out any of the required configuration settings for any custom configurations, types or analyzers you create.

If you need you can customise any area of the DefaultIndexConfiguration by copying the XML in and modifying it, such as Field Type Mapping, Computed Fields, Include and Exclude fields and more!

Finally don’t forget to reference your new custom index configuration in the indexes that should use them via the configuration xml node.

<configuration xmlns:patch="">
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="microsite_wildcard_index_web" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>
<param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
<!– Set the ref property to the XML path of your custom
IndexConfiguration node–>
<configuration ref="contentSearch/wildCards" />
<strategies hint="list:AddStrategy">
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />
<commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
<policies hint="list:AddCommitPolicy">
<policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
<locations hint="list:AddCrawler">
<crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">

And that’s it

Resolved the Server Error on the Index Manager and created a custom IndexConfiguration.

Using a custom one really is valuable when you are having a highly bespoke search or only searching certain types of Items and/or small number of Fields. You can create really lean indexes vastly improving search performance.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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 )

Connecting to %s