Custom Solr index conflict between IncludeTemplates and ExcludeTemplates nodes
If you have a configuration file to define a custom Solr index that meets the following:
- inherits the node
documentOptions
from the defaultdefaultSolrIndexConfiguration
. - defines an
AddIncludedTemplate
node.
This configuration is not allowed. Here is an example:
<configuration>
<sitecore>
<contentSearch>
<indexConfigurations>
<customIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
<documentOptions ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/documentOptions">
...
</documentOptions>
</customIndexConfiguration>
</indexConfigurations>
</contentSearch>
</sitecore>
</configuration>
By having this configuration you will start to see the following output in the logs:
34904 2021:08:14 14:47:48 WARN You have specified both
IncludeTemplates and ExcludeTemplates.
This logic is not supported. Exclude templates will be ignored.
Why is that? The defaultSolrIndexConfiguration
already defines an AddExcludedTemplate
node. It is not possible to have in the same index configuration both AddIncludedTemplate
and AddExcludedTemplate
at the same time.
How to fix it? Do not inherit the documentOptions
node from the defaultSolrIndexConfiguration
when you want to add an AddIncludedTemplate
node. Instead, create a new documentOptions
and copy the configuration you need from the defaultSolrIndexConfiguration
:
<documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
<indexAllFields>false</indexAllFields>
<fields hint="raw:AddComputedIndexField">
...
</fields>
<include hint="list:AddIncludedTemplate">
...
</include>
</documentOptions>
If you are using SXA, you should use SXA Item Crawlers. See Configure SXA indexing for more information.
Credits
Photo by Markus Spiske / Unsplash
comments powered by Disqus