Custom Boost Matching Function/Extension

Vote:
 

Hi,

I am using Episerver version 7 and Find version compatible with that.

I have a property defined in each pagetypes called boostFactor,
Ideally I would like to pass this property in boost matching function, so that not to hard-code the value.
I would like to use that property in


.BoostMatching(x => x.MatchType(typeof(ProductPage)), x.BoosFactor).?

It gives me an error as boost double value is not connected to filter at all.
How do I dynamically pass the boost factor from the current page in the above example or if I need to extend it.

Can any one please write up a snippet how to achieve this?

Many thanks,
Naz

#123223
Jun 29, 2015 10:33
Vote:
 

It is not possible to specify boost parameter directly from a document property, but you can probably configure some descrete levels like this:

.BoostMatching(x => x.BoostFactor.Match(2), 2)
.BoostMatching(x => x.BoostFactor.Match(3), 3)
.BoostMatching(x => x.BoostFactor.Match(4), 4)
.BoostMatching(x => x.BoostFactor.Match(5), 5)
#123286
Jun 30, 2015 17:21
Vote:
 

Thanks very much for your reply.

The way you mentioned above, it will still be hard-coded as I can see, the  second parameter takes 2, 3, 4 and 5 which is hard-coded.
Correct me if i am wrong.

Cheers,
Naz

#123296
Jul 01, 2015 9:48
Vote:
 

Yes, the possible boosting factor values are predefined, but boosting is controlled by the BoostFactor property value. This is not the same as you wanted, but somewhat close. Basically the expressions above mean:

For pages having BoostFactor property value equal 2, boost with factor 2
For pages having BoostFactor property value equal 3, boost with factor 3
etc...

#123298
Jul 01, 2015 10:15
Vote:
 

Hi,

Thanks for your prompt response. I understood it now.

One more question, I am using UnifiedSearch here, as it is generalised and
will contain documents with pages. Do you think I still need to use matchTypeHierarchy in here to be specific about type?
Hence my search query look like this as below. I needed to typecast it to SitePageData to get the Boost factor property enabled.
Can you see any problem with the code below? 


ITypeSearch<ISearchContent> query = SearchClient.Instance
.UnifiedSearch(Language.English)
.For(this.Query)
.BoostMatching(x => ((SitePageData)x).BoostFactor.Match(0.1), 0.1)
.Track()
.Skip((PagingPage - 1) * PageSize)
.ApplyBestBets()
.Take(PageSize);

Many thanks once again,
Naz

#123302
Jul 01, 2015 10:41
Vote:
 

Typecasting is fine, this expression is only used to build a boosting filter. Actual search results will never go through this expression.

#123318
Jul 01, 2015 14:08
Vote:
 

Thanks, yes I have tested it, and found no issues. 

#123320
Jul 01, 2015 14:57
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.