Applying sort only on N number of items

Vote:
 

Hi guys,

I have a page with DateTime property, "PageDate" and property "PageRank"

There is a requirement where I need to apply OrderBy for search pages which have "PageDate" in future first and ThenBy "PageRank".

Thing that complicates this is the requirement also says that editors also have an option to controll how many items can be sorted like this. There is an option for 1-3 items.

Basically something like promoted results but only with an option to choose how many items to be promoted.

I tried with getting only promoted results and than combining with normal and excluding duplicates.

Downside of this approach is duplicates in normal search results, incorrectly loaded result count and Facet count.

Also I tried with just one query and sorting by "PageDate" then by "PageRank" but then I can't controll how many items are sorted.

If anyone has any suggestion it would be really helpfull.

I'm using EPiServer.CMS version 12.15.1 and EPiServer.Find 14.2.4

Thanks,
Zoran   

#302339
Edited, May 25, 2023 14:40
Vote:
 

Instead of deduplicating after the results come back you could with 2 search queries

  1. Get the results back of the prioritized 
  2. Then pass an exclusion in to the second query of the non sorted results with each contentreference id to exclude it from the results

This would leave you with pagination only working for the second layer so you'd have to show the promoted results on top of the normal set of results. E.g. if your pagination number is 9 you'd put a row of the 3 artifically in front of the main results.

If you have pagination you can then combine result total count 

#302402
May 26, 2023 10:11
Vote:
 

Hi Scott,

Thanks for reply. 

I have implemented it like that but I was trying to do that in one query with just sorting to avoid complexity.

But I can't limit the number of prometed items. 

I guess that two queries is the way to go.

#302458
May 27, 2023 14:33
Scott Reed - May 30, 2023 13:52
I understand, I did think of multisearch as you can do 10 queries in 1 request but you'd need the result back first so that's not possible. Good luck with it!
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.