Copied to clipboard

Flag this post as spam?

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


  • Hefin Jones 39 posts 161 karma points
    Jun 18, 2019 @ 14:40
    Hefin Jones
    0

    Umbraco 8 Examine Index - supportProtected

    Hello!!

    Does anyone know how to enable "supportProtected" on an Examin index - in v7 we could do this via the examinesettings.config file - but the config files are no longer available in v8.

    Any ideas?

  • mmaty 95 posts 224 karma points
    Jul 19, 2019 @ 09:42
    mmaty
    0

    There is a ContentValueSetValidator class:

    var index = new LuceneIndex("SitemapIndex",
        CreateFileSystemLuceneDirectory("SitemapIndex"),
        new FieldDefinitionCollection(
            new FieldDefinition("updateDate", FieldDefinitionTypes.DateTime),
            new FieldDefinition("changeFrequency", FieldDefinitionTypes.Float)
        ),
        new StandardAnalyzer(Version.LUCENE_30),
        new ContentValueSetValidator(true, includeItemTypes:new string[]{ "BlogPost", "TextPage", "BlogOverview" }) );
    

    ContentValueSetValidator has a second constructor with a parameter 'supportProtectedContent'. I don't have any further insights, since the code of this class is not self-explanatory:

    https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Examine/ContentValueSetValidator.cs

  • Ismail Mayat 4511 posts 10061 karma points MVP 2x admin c-trib
    Sep 25, 2019 @ 07:22
    Ismail Mayat
    0

    Having this same issue. I already have the index the external one i need to just allow SupportProtectedContent and set it to true. Don't want to have to go through setting up the whole index again.

  • Marc Goodson 1622 posts 10744 karma points MVP 6x c-trib
    Sep 25, 2019 @ 09:10
    Marc Goodson
    0

    Hi Ismail

    enter image description here

    It looks like in the source for examine

    https://github.com/Shazwazza/Examine/blob/864168c7f019908242dd56197e075edea5ee77cf/src/Examine/Providers/BaseIndexProvider.cs

    that each index does have a ValueSetValidator property

    and this can be set to be a new instance of a ContentValueSetValidator which takes a parameter to support protected content or not...

    however as this property has it's 'set' protected, it can only be set via the constructor for the index, which you can only do when creating it afresh...

    enter image description here

    ... but I might be misunderstanding! and there may be another way...

    but looks like removing the existing index and creating a new one with the desired configuration is the way to go...

  • Ismail Mayat 4511 posts 10061 karma points MVP 2x admin c-trib
    Sep 25, 2019 @ 09:12
    Ismail Mayat
    0

    Marc,

    Callum seems to think you can over ride, but i did see that protected property so could be you remove then re add afresh

  • Ismail Mayat 4511 posts 10061 karma points MVP 2x admin c-trib
    Sep 25, 2019 @ 13:54
    Ismail Mayat
    100

    Ok so superstar callum came up with the goods with a package see https://github.com/callumbwhyte/umbraco-config-contrib

  • Bjarne Fyrstenborg 1236 posts 3664 karma points MVP 5x c-trib
    Mar 25, 2021 @ 15:04
    Bjarne Fyrstenborg
    1

    Currently it seems the Umbraco Examine Config package has some issues, which cause a boot error - at least while testing on Umbraco v8.12.2: https://github.com/callumbwhyte/umbraco-examine-config/issues

    I implemented the following instead to enable SupportProtectedContent in ExternalIndex and close to the example documented here: https://our.umbraco.com/documentation/reference/searching/examine/indexing/#changing-ivaluesetvalidator

    using Examine;
    using Umbraco.Core;
    using Umbraco.Core.Composing;
    using Umbraco.Core.Scoping;
    using Umbraco.Core.Services;
    using Umbraco.Examine;
    using Umbraco.Web.Search;
    
    namespace My.Core.Composing
    {
        public class CustomizeIndexComposer : IUserComposer
        {
            //[ComposeAfter(typeof(ExamineComposer))]
            public void Compose(Composition composition)
            {
                // replace the default IUmbracoIndexConfig definition
                composition.RegisterUnique<IUmbracoIndexConfig, CustomIndexConfig>();
            }
        }
    
        // inherit from the default
        public class CustomIndexConfig : UmbracoIndexConfig, IUmbracoIndexConfig
        {
            private readonly IPublicAccessService _publicAccessService;
            private readonly IScopeProvider _scopeProvider;
    
            public CustomIndexConfig(IPublicAccessService publicAccessService, IScopeProvider scopeProvider)
                : base(publicAccessService)
            {
                _publicAccessService = publicAccessService;
                _scopeProvider = scopeProvider;
            }
    
            // explicit implementation - overrides base class.
            IContentValueSetValidator IUmbracoIndexConfig.GetContentValueSetValidator()
            {
                bool supportProtectedContent = true;
    
                return new ContentValueSetValidator(false, supportProtectedContent, _publicAccessService, _scopeProvider);
            }
    
            // explicit implementation - overrides base class
            IValueSetValidator IUmbracoIndexConfig.GetMemberValueSetValidator()
            {
                var excludeFields = Umbraco.Core.Constants.Conventions.Member.GetStandardPropertyTypeStubs().Keys;
    
                // include everything except the above
                return new MemberValueSetValidator(null, null, null, excludeFields);
            }
    
            // explicit implementation - overrides base class.
            IContentValueSetValidator IUmbracoIndexConfig.GetPublishedContentValueSetValidator()
            {
                bool supportProtectedContent = true;
    
                return new ContentValueSetValidator(true, supportProtectedContent, _publicAccessService, _scopeProvider);
            }
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft