Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

JavaScript results sorting - SearchUnit - Forum

Welcome Guest Search | Active Topics | Log In | Register

Options
DMacy
#1 Posted : Tuesday, October 11, 2022 9:36:42 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 133
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?
Jim
#2 Posted : Wednesday, October 12, 2022 7:14:59 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
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!


DMacy
#3 Posted : Wednesday, October 12, 2022 7:37:28 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 133
Thanks, Jim! I'll give that a try.
DMacy
#4 Posted : Wednesday, October 12, 2022 7:44:12 PM
Rank: Advanced Member

Groups: Registered

Joined: 9/1/2010
Posts: 133
resultObject.Results only contains one page's worth of results, right? How would I access all results to sort them before presenting them?
Jim
#5 Posted : Wednesday, October 12, 2022 9:05:22 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,667
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!


Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.




About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.