首页 > 解决方案 > 向 Umbraco 8 成员索引添加一个字段

问题描述

我通过添加一些自定义字段扩展了 Umbraco 8 成员类型。

我需要能够通过这些字段之一“organisationName”(这是它的别名)来搜索成员,所以在查看检查时,我尝试将其添加到成员索引中,如下所示:

private readonly IExamineManager _examineManager;

    public CustomizeIndexComponent(IExamineManager examineManager)
    {
        _examineManager = examineManager;
    }

    public void Initialize()
    {
        // get the external index
        if (!_examineManager.TryGetIndex("MembersIndex", out var index))
            return;

        // add a custom field type
        index.FieldDefinitionCollection.TryAdd(new FieldDefinition("organisationName", FieldDefinitionTypes.FullText));

    }

当我在 TryAdd 之后设置断点时,我可以看到新字段,但是在后台,当我查看成员索引时,它不存在。

我是否以正确的方式进行此操作,因为我实际上可以将我的字段添加到成员索引中,还是应该基于成员创建一个新的自定义索引?

标签: umbracoumbraco8examine

解决方案


我认为大多数人在这里创建自己的索引: https ://our.umbraco.com/forum/developers/extending-umbraco/72299-umbraco-7-backoffice-member-search-by-custom-properties#comment-277928

但我个人只会使用 GetMembersByPropertyValue 访问会员 API。使用 umbraco api 控制器调用成员 api 非常容易。 https://our.umbraco.com/documentation/reference/management/services/memberservice/ (这里是一个例子,只是为了展示几行)。

/umbraco/api/SearchMemberApi/ReturnMembersWith

在此处输入图像描述


推荐阅读