Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Samuel Butler 8 posts 130 karma points c-trib
    Nov 02, 2019 @ 02:00
    Samuel Butler
    0

    Examine: How does one exclude node types from indexing

    In Umbraco 7 one could exclude node types via the Examine.config file. Now this file is gone how do we do this. I have searched high and low online on how to do this but I have found nothing helpful.

  • Mario Lopez 168 posts 958 karma points MVP 4x c-trib
    Nov 02, 2019 @ 03:58
    Mario Lopez
    0

    Hey I know your face! ;) To exclude nodes use <ExcludeNodeTypes> in the /config/examineIndex.config.

    More info from someone you already know: https://our.umbraco.com/documentation/Reference/Searching/Examine/overview-explanation

  • Samuel Butler 8 posts 130 karma points c-trib
    Nov 02, 2019 @ 05:35
    Samuel Butler
    0

    Cheers Mario, that was definitely the way to do it in Umbraco 7, but that is all gone in Umbraco 8. I have worked out what I needed to do from this post:

    https://our.umbraco.com/forum/umbraco-8/95915-umbraco-8-examine-indexes

    Essentially I need to create a custom indexer as it seems I cannot modify the ContentValueSetValidator used by the builtin External indexer.

    Cheers again :)

  • Mario Lopez 168 posts 958 karma points MVP 4x c-trib
    Nov 02, 2019 @ 05:38
    Mario Lopez
    0

    I misread, I thought you wanted it for V7.

  • Samuel Butler 8 posts 130 karma points c-trib
    Nov 02, 2019 @ 05:36
    Samuel Butler
    100

    Worked it out using this post:

    https://our.umbraco.com/forum/umbraco-8/95915-umbraco-8-examine-indexes

    public class SearchIndexCreator : LuceneIndexCreator, IUmbracoIndexesCreator
    {
        private readonly IProfilingLogger _ProfilingLogger;
        private readonly ILocalizationService _LanguageService;
    
        public SearchIndexCreator(IProfilingLogger profilingLogger, ILocalizationService languageService)
        {
            _ProfilingLogger = profilingLogger ?? throw new System.ArgumentNullException(nameof(profilingLogger));
            _LanguageService = languageService ?? throw new System.ArgumentNullException(nameof(languageService));
        }
    
        public override IEnumerable<IIndex> Create()
        {
            return new[] { CreateCustomIndex() };
        }
    
        private IIndex CreateCustomIndex()
        {
            var contentTypesToExclude = new[]
            {
                ...
            };
    
            var index = new UmbracoContentIndex(
                "SearchIndex",
                CreateFileSystemLuceneDirectory("Search"),
                new UmbracoFieldDefinitionCollection(),
                new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30),
                _ProfilingLogger,
                _LanguageService,
                new ContentValueSetValidator(true, excludeItemTypes: contentTypesToExclude));
            return index;
        }
    }
    
  • Samuel Butler 8 posts 130 karma points c-trib
    Nov 05, 2019 @ 06:34
    Samuel Butler
    0

    In case anyone comes along and sees this post, Callum Whyte has actually put together a package that allows you to do this via a config file. I have not used it myself yet as unfortunately the project I am working one requires to be as vanilla as possible.

    https://our.umbraco.com/packages/developer-tools/examine-config/

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies