Can the search results on the member search page be sorted by an ExtendedAttributes or ProfileFields field?
Can the search results on the member search page be sorted by an ExtendedAttributes or ProfileFields field?
It appears to be working now. I am now passing the search results list as an array instead of a list. Thanks.
Again to reiterate, retrieving all users in this way, especially if you then page results of your new sorted list, is going to be quite expensive. At that point it might be better to set up a custom data store (i.e., your own database table) that keeps your custom fields referenced by userid, and then use the user list API and provide a list of ids via the ContentIds option with SortBy=ContentIdsOrder. Then you can return that pre-paged, pre-sorted list via your widget extension.
Hi Stephen,
Could you please explain this procedure a bit more. What would I pass into my widget extension method, and what would I pass out? What would be the pseudocode for the procedure?
You need a custom table to store whatever you want to sort y and the contentId and any associated code to make your call. That list of Ids can be passed to the User list and be returned in the same order.
https://community.telligent.com/community/11/w/api-documentation/63544/userslistoptions-in-process-api-supplementary-type
I am returning the sorted Users list from my widget extension, but the users are no longer being filtered on the Member Search page. How can I get the filtering working again?
There is not enough information here to answer this because we don't know what you did or how anything was implemented. If the expectation is that you added your own extension to replace a call on that page and it would just work, then that won't be the case.
Hi,
Here's the C# code:
public class MyUsers { public string GetContentIds() { SqlDataAccess sd = new SqlDataAccess(); using (SqlCommand cmd = sd.GetCommand("ibby_Get_Sorted_User_Content_Ids")) { cmd.CommandType = CommandType.StoredProcedure; DataTable dt = sd.Execute(cmd); StringBuilder sb = new StringBuilder(); for (int i = 0; i < dt.Rows.Count; i++) { sb.Append(dt.Rows[i]["ContentId"].ToString()); if (i != dt.Rows.Count - 1) sb.Append(","); } return sb.ToString(); } } public PagedList<Telligent.Evolution.Extensibility.Api.Entities.Version1.User> GetUsers() { UsersListOptions options = new UsersListOptions(); options.ContentIds = GetContentIds(); options.SortBy = "ContentIdsOrder"; return Apis.Get<Users>().List(options); } }
And search.vm
#set($filters = $core_v2_page.GetFormValue('filters')) ## perform search #set($count = 0) #set ($searchListOptions = "%{ Query = $searchQuery, Sort = 'titlesort', PageIndex = $pageIndex, PageSize = $pageSize }") $searchListOptions.Add("Filters", "type::user${filters}") ##set ($searchResults = $core_v2_searchResult.List($searchListOptions)) #set ($searchResults = $!$ibby_v1_UserData.GetUsers()) ## Render Search Results #set ($hasMore = false) #set ($currentPagedQuantity = ($searchResults.PageIndex + 1) * $searchResults.PageSize) #if ($searchResults.TotalCount > $currentPagedQuantity) #set ($hasMore = true) #end #foreach ($user in $searchResults) #beforeall <div class="content-list thumbnail ui-masonry margin-top" id="$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.UniqueId('thumbnails'))" data-columnclass="thumbnail-column"> #each ##set ($user = false) ##foreach ($resultUser in $result.Users) ## #set ($user = $resultUser) ###end
These are 2 completely different methods for getting users so filters are not going to work. You use the users API, the members page is based on search. These methods are not interchangeable.
Realistically, you could just use Apis.Get<ISearchIndexing>().Events, handle the BeforeBulkIndex event for users, stuff a custom field in the document for the value you want to sort by and then modify any call the Apis.Get<ISearchResults> to include your custom sort in the query
community.telligent.com/.../searchindexing-in-process-api-service
How often does the BeforeBulkIndex event get fired in a user's lifecycle? Is it only once? My custom sort field can change quite often, and it might not have a value before the event gets fired. Will that be a problem?
That event gets fired before altered users get changed in the index, which varies by how often the job runs and how many changes need to be processed. You still will have to store this value somehow and read it when the event is fired