Copied to clipboard

Flag this post as spam?

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


  • Dave Pearcey 46 posts 178 karma points
    Jun 09, 2020 @ 13:45
    Dave Pearcey
    0

    search Member index by custom fields

    Hi!

    I've tried to add custom fields to the member index, in order to be able to search and sort by custom fields. This is to replace use of the memberservice, which is extremely costly with the amount of members there are.

    I took the code from the documentation, here: https://our.umbraco.com/documentation/reference/searching/Examine/indexing/#changing-ivaluesetvalidator

    I've tried including certain fields, and I've tried the exact example in that link. When rebuilding the index, nothing is any different.

    Is there something I'm missing here? does anyone have a link to a working example?

    My full code for this to be perfectly clear as to where I currently am:

    using Examine;
    using Umbraco.Core.Composing;
    using Umbraco.Core.Services;
    using Umbraco.Examine;
    using Umbraco.Core;
    
    namespace lib.util.Umbraco
    {
    public class CustomizeIndexComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            // replace the default IUmbracoIndexConfig definition
            composition.RegisterUniqueFor<IUmbracoIndexConfig, CustomIndexConfig>();
        }
    }
    
    // inherit from the default
    public class CustomIndexConfig : UmbracoIndexConfig, IUmbracoIndexConfig
    {
        public CustomIndexConfig(IPublicAccessService publicAccessService) : base(publicAccessService)
        {
        }
    
        // explicit implementation - overrides base class.
        // GetMemberValueSetValidator is used for the MemberIndex.
        IValueSetValidator IUmbracoIndexConfig.GetMemberValueSetValidator()
        {
            // NOTE - by default Umbraco only includes a small subset of fields for the member index for
            // security reasons, however you may want to include a larger set of data in the member index.
            // This example will include all data for a member excluding the built in property values.
    
            // all built in member properties to exclude (i.e. Password question, etc...)
            var excludeFields = Constants.Conventions.Member.GetStandardPropertyTypeStubs().Keys;
    
            // include everything except the above
            return new MemberValueSetValidator(null, null, null, excludeFields);
        }
    }
    }
    
  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Jun 10, 2020 @ 09:30
  • Dave Pearcey 46 posts 178 karma points
    Jun 10, 2020 @ 12:28
    Dave Pearcey
    0

    Everything said there points to creating a custom index. I just want to modify the existing member index, as i dont want there to be multiple indexes unnecesarily.

    The link to the documentation and my code are supposed to just override GetMemberValueSetValidator() to do this, but it doesn't appear to do anything at all. building indexes doesnt even step into it..

  • Dee 118 posts 338 karma points
    Aug 28, 2020 @ 10:31
    Dee
    0

    Hey Dave,

    did you manage to get the job done? If yes, what was your approach?

    Thanks,

    Dee

  • Robin Hansen 135 posts 368 karma points
    Sep 08, 2020 @ 11:22
    Robin Hansen
    0

    I would like to know as well :)

  • Dee 118 posts 338 karma points
    Sep 09, 2020 @ 07:05
    Dee
    1
  • Stefan Kip 1614 posts 4131 karma points c-trib
    Dec 09, 2020 @ 11:45
    Stefan Kip
    0

    @Dee just wanted to say thanks! :-)

  • Dee 118 posts 338 karma points
    Dec 09, 2020 @ 12:22
    Dee
    0

    YW!

Please Sign in or register to post replies

Write your reply to:

Draft