Rank: Advanced Member
Groups: Registered
Joined: 9/1/2010 Posts: 136
|
In my ASP.NET implementation of SearchUnit, I use a class that implements IComparer(Of Keyoti.SearchEngine.Search.ResultItem) to provide a custom sorting algorithm. Is there a way to do this with the JavaScript/JQuery/AJAX implementation of SearchUnit?
|
Rank: Advanced Member
Groups: Administrators, Registered
Joined: 8/13/2004 Posts: 2,669 Location: Canada
|
Yes you can add this keyotiSearch.onResultsObtained = function(resultObject){ ///sort/filter etc }; Quote: Called when results are obtained from the server. Provides opporunity to manipulate the results before they are displayed. This method implementation is empty and can be overridden safely. The resultObject has properties Exception, IgnoredWords, LiveDataSamples, NumberOfResults, QueryKeywords, Results array. Results array items contain Content, CustomData, CustomDataDictionary, KeywordHitMap, Location, SecurityGroups, Summary, Title, UriString, UriStringAsStored, Weight (modifying weight will not change result ordering which is already determined).
So add that and you should see a property, resultObject.Results which contains the results, you can sort it there. -your feedback is helpful to other users, thank you!
|
Rank: Advanced Member
Groups: Registered
Joined: 9/1/2010 Posts: 136
|
Thanks, Jim! I'll give that a try.
|
Rank: Advanced Member
Groups: Registered
Joined: 9/1/2010 Posts: 136
|
resultObject.Results only contains one page's worth of results, right? How would I access all results to sort them before presenting them?
|
Rank: Advanced Member
Groups: Administrators, Registered
Joined: 8/13/2004 Posts: 2,669 Location: Canada
|
Good point, I forgot about that. You can instead use a plug-in to do the sorting on the server https://keyoti.com/produ...Using%20A%20Plug-in.htm
you can use the event Code: ResultItemsFinalized The search result items have been found and sorted, Data contains a Keyoti.SearchEngine.Utils.ResultItemList of ResultItem objects - the order and content of which may be changed.
to do access the results and sort/filter as desired. I don't know if it is feasible in your situation but you can control the sorting if it involves custom data, from Javascript, see https://keyoti.com/produ.../CustomDataFiltersJS.htm-your feedback is helpful to other users, thank you!
|