umbraco - 向 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 之后设置断点时,我可以看到新字段,但是在后台,当我查看成员索引时,它不存在。
我是否以正确的方式进行此操作,因为我实际上可以将我的字段添加到成员索引中,还是应该基于成员创建一个新的自定义索引?
解决方案
我认为大多数人在这里创建自己的索引: 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
推荐阅读
- rest - 如何使用 Servicenow rest api 接受事件
- dart - 为什么错误构造函数不返回错误?
- ssh - 为 gcloud cli 自动附加 ssh 标志
- fonts - XeLaTeX Nono 字体复制和粘贴失败
- powershell - 在powershell中获取大文件的md5校验和
- php - Symfony:表格中特定条件的数据获取方法
- javascript - 禁用材料表中的工具提示
- python - 每次使用苹果登录时,Django都会创建新用户
- python - 这个展平层在我的 LSTM 中做了什么?
- spring-boot - Cassandra数据库关闭时的Spring security-oauth2自定义异常