I have extended the Umbraco 8 Member type by adding some custom fields.
I need to be able to search Members by one of these fields, 'organisationName' (that's it's alias), so when looking at Examine, I tried to add this to the members index like this:
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));
}
when I put a breakpoint on after the TryAdd I can see the new field, but in the back office it's not there when I look at the members index.
Am I going about this the right way, as in can I actually add my field to the members index, or should I create a new custom index based on the member?
I think most people create their own index like here: https://our.umbraco.com/forum/developers/extending-umbraco/72299-umbraco-7-backoffice-member-search-by-custom-properties#comment-277928
But I would personally just access the membership API with GetMembersByPropertyValue. It's very easy to make a call to the member api with umbraco api controller. https://our.umbraco.com/documentation/reference/management/services/memberservice/ (here an example just to show the few lines).
/umbraco/api/SearchMemberApi/ReturnMembersWith