SaaS CMS has officially launched! Learn more now.

Possibility to sort NewsPages by updated date and other pages by score in one list of results



Is there a way to sort NewsPages by updated date and other pages by score in the same results list, So that the oldest newpages get the lowest sort in the list ?

This is how my query looks like: 

var query = querySearch
.BoostMatching(x => x.MatchType(typeof(ContactPage)), 1.5d)
.BoostMatching(x => x.MatchType(typeof(ProgrammePage)), 1.5d)
.BoostMatching(x => x.MatchType(typeof(CoursePage)), 1.5d)

Thank you in advance!


Nov 10, 2020 8:50

Checked out auto boosting?

searchResult = client.Search<BlogPost>()

That will increase hits from newly published at least. It will be applied to all page types though so might be an issue. Otherwise boosting news article from last x days might be another option? Similar to this:

var searchResult = client.Search<Car>()
    .BoostMatching(x => x.InStock.Match(true), 1.5)
    .BoostMatching(x => x.SalesMargin.GreaterThan(0.2), 1.5)
Nov 10, 2020 9:06

Hi Daniel,

Yes, I have tried autoboosting, it didn't work as I wanted..

I didnt quit understand the second exemple:

.BoostMatching(x => x.SalesMargin.GreaterThan(0.2), 1.5)

If I want to sort newspages after SearchPublishDate , so my oldest news rankes low in my list, how to do it with boosting ? 

Nov 10, 2020 9:22

Ok too bad. With boost filters my idea was that if you boost the last month worth of news pages a little you will increase the probability of them ending up on top. Otherwise I can't see any other option than having a secondary search functionality just for news and displaying them separately. You can easily sort them by publication date

Tricky to support both sorting by relevance and sorting some specific pages by date in the same result. Not sure that is possible? Maybe someone else knows? 

Nov 10, 2020 9:32

Alright, maybe I can get around it if I make the oldest newspages have the lowest score, like this.

So that the Newspages that are older then 2 years get a low score and ranks down the list, but what is the lowest score that I can use ?

Is my following code useable ?

.BoostMatching(x=>x.MatchType(typeof(NewsPage)) & x.SearchPublishDate.LessThan(DateTime.Now.AddYears(-2)),0.01d) 

Nov 10, 2020 10:48

Yeah I would go with something like that. Easy and gets the job done good enough. 

Nov 10, 2020 12:23
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.