Umbraco 7 BackOffice Member Search By Custom Properties
Hi All!
Hope everyone is doing well! Just a quick question regarding BackOffice search in Umbraco 7 : we have a site with a lot of members with a few custom (text) properties we'd like to search by.
We've updated the InternalMemberIndexer to add these fields, and can see them in the index set using Luke.
However, in Umbraco's back office, we seem to only be able to find members by the 'native' umbraco fields (loginName, email etc)
Does anyone know if it's easy to include these custom fields in the backoffice Umbraco member search? (we're keen to know if it can be done using the existing search that comes with Umbraco if possible)
No worries if not, but thought I'd ask the question in case there was a quicker way than having a custom dashboard control.
I just looked through the source code, and eventually the search makes a call in the EntityController to this ExamineSearch function, and if it's a member search the fields searched are hardcoded to be:
I have a lot of member profiles which are searchable by the front-end based on text fields and other types of fields.
Is this thread saying that its just not possible to search members based on any other fields apart from the Umbraco defaults?
Very frustrating if so.....
I literally just re-coded a big project to use Umbraco's member stuff. Previously I was just using standard DocTypes as member profiles and linking then back to a Umbraco member object.
I assumed this was bad practice and now finding out members are not searchable????
Anyone got any help with this. A lot of re-work for me to do if not :(
I dont think David's solution is correct here. It will work for a front end, but not the umbraco back office.
I've tried to add more attributes to the ExamineSettings.config and ExamineIndex.config, when i test the the indexer on the back office, it gets results, but when I try to use the umbraco member searcher, it doesnt bring back any results.
It looks like the code for MemberSearch.ascx.cs needs to be amended. How do i go abouts doing that?
Satpal - Yes Davids code is for front end, thats the easy bit. To override the back office, as you've found you need to use ISearchableTree, however finding documentation or examples for it is very hard.
I did try it a few weeks back but gave up so would welcome any examples you find so we can work out how to do it :)
The members are also shown in this tree searcher, custom properties can be searched in a custom tree searcher class.
You have to implement the ISearchableTree interface something like this:
public class MemberTreeController : Umbraco.Web.Search.ISearchableTree
{
public string TreeAlias
{
get
{
return "member";
}
}
public IEnumerable<SearchResultItem> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)
{
// MemberTreeController
//public IEnumerable<SearchResultItem> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)
//{
// return _treeSearcher.ExamineSearch(Umbraco, query, UmbracoEntityTypes.Member, pageSize, pageIndex, out totalFound, searchFrom);
//}
// Normaly this is done by UmbracoTreeSearcher.ExamineSearch
var searcher = Constants.Examine.InternalSearcher;
var internalSearcher = ExamineManager.Instance.SearchProviderCollection[searcher];
var raw = internalSearcher.CreateSearchCriteria().RawQuery(query);
var result = internalSearcher.Search(raw, Convert.ToInt32(pageSize * (pageIndex + 1)));
totalFound = result.TotalItemCount;
var pagedResult = result.Skip(Convert.ToInt32(pageIndex));
return MemberFromSearchResults(pagedResult.ToArray());
}
Then in the ApplicationStarted event you can disable the default ISearchableTree controller
public class RegisterEvents : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarting(umbracoApplication, applicationContext);
}
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
//remove the default content one (which is the content tree)
SearchableTreeResolver.Current.RemoveType<Umbraco.Web.Trees.MemberTreeController>();
}
}
Thank you Solomon for taking the time to post this. I've not had any time to look further but will give you code a go - the missing part for me I think was registering the events, sort of makes sense now doh!
Umbraco 7 BackOffice Member Search By Custom Properties
Hi All!
Hope everyone is doing well! Just a quick question regarding BackOffice search in Umbraco 7 : we have a site with a lot of members with a few custom (text) properties we'd like to search by.
We've updated the InternalMemberIndexer to add these fields, and can see them in the index set using Luke.
However, in Umbraco's back office, we seem to only be able to find members by the 'native' umbraco fields (loginName, email etc)
Does anyone know if it's easy to include these custom fields in the backoffice Umbraco member search? (we're keen to know if it can be done using the existing search that comes with Umbraco if possible)
No worries if not, but thought I'd ask the question in case there was a quicker way than having a custom dashboard control.
Thanks for your help!
Kind regards,
Roger Davies
Hi
Having the exact same problem - anyone knows if this is possible?
Best Regards
Claus
Hello Claje did you find any solution on this ?
thank you
Angelo
I just looked through the source code, and eventually the search makes a call in the EntityController to this ExamineSearch function, and if it's a member search the fields searched are hardcoded to be:
eg:
so this is why the custom fields aren't searched, and there doesn't currently appear to be an option to configure this
I have created a 'feature request' for this functionality which you can vote for / comment on if you would find this kind of change useful :
http://issues.umbraco.org/issue/U4-8417
Im running 7.5.9 and found out the hard way that its indeed hardcoded.
Doesnt seem to be in 7.6 either...
Hi,
Is there any news on this?
I have a lot of member profiles which are searchable by the front-end based on text fields and other types of fields.
Is this thread saying that its just not possible to search members based on any other fields apart from the Umbraco defaults?
Very frustrating if so.....
I literally just re-coded a big project to use Umbraco's member stuff. Previously I was just using standard DocTypes as member profiles and linking then back to a Umbraco member object.
I assumed this was bad practice and now finding out members are not searchable????
Anyone got any help with this. A lot of re-work for me to do if not :(
Kind Regards
David
Hi Guys,
I got examine searching working on the members. I had to create a custom indexer & searcher.
Here is what I did.
First - I create a new IndexSet within the ExamineIndex.config.
Second - I created a new Indexer within the ExamineSettings.config. This needs adding within ExamineIndexProviders/providers.
Third - I created a new Searcher within the ExamineSettings.config. This needs adding within ExamineSearchProviders/providers.
NOW YOU SHOULD BE ABLE TO SEARCH CUSTOM FIELDS!!!
Here is an example of one of my simple member searches.
Hope this helps someone. It look we a while to figure out.
Kind Regards
David
I dont think David's solution is correct here. It will work for a front end, but not the umbraco back office.
I've tried to add more attributes to the ExamineSettings.config and ExamineIndex.config, when i test the the indexer on the back office, it gets results, but when I try to use the umbraco member searcher, it doesnt bring back any results.
It looks like the code for MemberSearch.ascx.cs needs to be amended. How do i go abouts doing that?
Has anyone got this working?
I'm not sure I understand this:
http://issues.umbraco.org/issue/U4-2676
seems to be the recommended way to implement extending the backoffice search. so we'll have to intercept the search somewhere.
Satpal - Yes Davids code is for front end, thats the easy bit. To override the back office, as you've found you need to use ISearchableTree, however finding documentation or examples for it is very hard.
I did try it a few weeks back but gave up so would welcome any examples you find so we can work out how to do it :)
Si
The example here http://issues.umbraco.org/issue/U4-2676 is only for the three searcher
The members are also shown in this tree searcher, custom properties can be searched in a custom tree searcher class.
You have to implement the ISearchableTree interface something like this:
Then in the ApplicationStarted event you can disable the default ISearchableTree controller
Thank you Solomon for taking the time to post this. I've not had any time to look further but will give you code a go - the missing part for me I think was registering the events, sort of makes sense now doh!
Hi,
I'm trying to do something similar but with a custom section (so not using Examine). Would you be able to share the MemberFromSearchResults method?
Hi Salomons
Could please share the MemberFromSearchResults code with us?
Do I need to add my own interface as its referenced to Umbraco.Web.Search.ISearchableTree ?
My umbraco versiom i am using. Umbraco version 7.3.7
is working on a reply...