Copied to clipboard

Flag this post as spam?

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


  • O Larsson 1 post 71 karma points
    Jan 17, 2023 @ 10:16
    O Larsson
    0

    Indexing the groups associated with a member

    Im trying to index certain parts of members using Lucene. I have been successful in indexing custom fields like "country" and "zipcode". But when it comes to the member groups associated with a member im struggling to understand how to do it. Here is the code i have at the moment, if someone coudl push me in the right direction I would appreciate it:

    using Examine;
    using Examine.Lucene;
    using Microsoft.Extensions.Options;
    using Umbraco.Cms.Core;
    using Umbraco.Cms.Core.Composing;
    using Umbraco.Cms.Core.Configuration.Models;
    using Umbraco.Cms.Core.Models;
    using Umbraco.Cms.Infrastructure.Examine;
    using Umbraco.Cms.Infrastructure.Examine.DependencyInjection;
    
    namespace Umbraco.Docs.Samples.Web.CustomIndexing
    {
      public class ConfigureMemberIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
      {
    
        private readonly IUmbracoIndexConfig _umbracoIndexConfig;
        private readonly IOptions<IndexCreatorSettings> _settings;
    
        public ConfigureMemberIndexOptions(
            IUmbracoIndexConfig umbracoIndexConfig,
            IOptions<IndexCreatorSettings> settings)
        {
          _umbracoIndexConfig = umbracoIndexConfig;
          _settings = settings;
        }
    
        public void Configure(string name, LuceneDirectoryIndexOptions options)
        {
          if (name.Equals(Constants.UmbracoIndexes.MembersIndexName))
          {
            options.Validator = new MemberValueSetValidator(null, null, new[] {
                "__Key", "NodeName", "gendergroup",
                 "__NodeTypeAlias", "__NodeId", "id", "groups" ,
                 "stagename", "birthdate", "firstName", "lastName",
                 "phone", "email", "address", "zipcode", "city", "country",
                 "language", "specialFeatures", "about", "mission"
                 }, null);
          }
        }
    
        public void Configure(LuceneDirectoryIndexOptions options) => Configure(string.Empty, options);
        public class SearchComposer : IComposer
        {
          public void Compose(IUmbracoBuilder builder)
          {
            builder.Services.ConfigureOptions<ConfigureMemberIndexOptions>();
          }
        }
      }
    
Please Sign in or register to post replies

Write your reply to:

Draft