Excluding content from being indexed in Find

Vote:
 

Hi,

It seems my initialization module where i try to exclude things from being index is pretty much ignored. So i guess i've done something wrong. For example, i'm trying to exclude page types from being indexed like this:

ContentIndexer.Instance.Conventions.ForInstancesOf<StartPage>().ShouldIndex(x => false);

But the startpage keep being indexed, and updated every time i publish it. So i tried another approach where i actually delete the page:

ContentIndexer.Instance.Conventions.ForInstancesOf<StartPage>().ShouldIndex(x =>
{
    ContentIndexer.Instance.Delete(x);
    return false;
});

But that wouldn't work either. I'm pretty sure it worked when i first added the code... Any ideas?

My module looks like this:

[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class FindInitialization : IInitializableModule
{
    public void Initialize(InitializationEngine context)
    {
        ContentIndexer.Instance.Conventions.ForInstancesOf<StartPage>().ShouldIndex(x => false);
    }
}
#231176
Nov 20, 2020 15:13
Vote:
 

Hi Jonas,

It looks OK and should work. Well works in our projects ;)

Does it make any difference if you change the module dependency in your module to: [ModuleDependency(typeof(EPiServer.Find.Cms.Module.IndexingModule))] so you can be sure your initialization happens after the Find initialization.

And your solution doesn't have code that would conflict with the above somewhere else? Do you have any third party add-ons that mights change Find behavior?

#231203
Nov 21, 2020 8:45
Vote:
 

If you publish your start page, can you check if it runs into your ShouldIndex function (by placing a breakpoint in debug mode/logging etc.)?

#231204
Nov 21, 2020 10:35
Vote:
 

Thanks for your suggestions, i'll look in to them and get back to you!

Edit:

You got me on the right track Antti. First of all, the ModuleDependency didn't make any difference, but you're are right, it should be set to IndexingModule anyway. But i did find a line of interferring code elsewhere!

This line really screw things up:

ContentIndexer.Instance.Conventions.ForInstancesOf<IContent>().ShouldIndex(x => !(x is IElementBlock));

Some one (not me of course :) ) wanted to exclude EPiServer Forms by adding this line, which (i believe) overrides my code since IContent is higher in the hierarchy?

When this line was removed my ShouldIndex function was called correctly.

#231252
Edited, Nov 23, 2020 13:15
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.