November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Praful,
First create your IShouldIndexInContentAreaConvention implementation:
public class ShouldIndexCopyBlockInContentAreaConvention : IShouldIndexInContentAreaConvention
{
public bool? ShouldIndexInContentArea(IContent contentInArea)
{
// Add whatever additional logic you need here!
if (contentInArea is CopyBlock)
{
return true;
}
return false;
}
}
Then go ahead and replace the default via an InitializableModule:
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Find.Cms.Module.IndexingModule))]
public class SearchConventionInitializationModule : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
ContentIndexer.Instance.Conventions.ShouldIndexInContentAreaConvention = new ShouldIndexCopyBlockInContentAreaConvention();
}
public void Uninitialize(InitializationEngine context) {}
}
This example is obviously ridiculously simple, you could also take a peek at the DefaultShouldIndexInContentAreaConvention (in EPiServer.Find.Cms.Conventions) where the published status of the content is checked before indexing (it's probably worth doing something similar).
Anyway, hope that gives you a starting point.
/Jake
Hi Jake,
First of all thank you so much, this example worked. Really helpful information. :)
Hi,
I have a requirement to allow content of ContentAreaItem item to be indexed with page content in SearchText and of course, I can’t use [IndexInContentarea] attribute due to some restrictions on referencing.
So, is it possible to do that with the help of
IContentIndexerConventions.ShouldIndexInContentAreaConvention
If it is, then how? I tried to find a code sample, but total waste of time. Can anyone help me with how to use this (ShouldIndexInContentAreaConvention) to allow a Block (say CopyBlock) to get it's content indexed.