Boosting with filters

Vote:
 

Ref, boosting documentation: http://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/Boosting-with-filters/

How can I boost string properties (a hit inside Heading and SubHeading is more relevant than MainIntro).

I have tried the code below, but that has no effect. If I use a bool property, it works as expected.

var result = SearchClient.Instance.Search()
                .For(query)
                .BoostMatching(x => x.Heading.Match(query), 2)
                .BoostMatching(x => x.SubHeading.Match(query), 2)                
                .Take(30)
                .GetContentResult();

I have also tried MatchContained(..), but the result order is unchanged.

#176322
Mar 16, 2017 8:10
Vote:
 

Would it not be better to boost the fields? Such as .InField(x => x.Heading, 2) That way it would work with stemming as well, and not just an exact match.

Also, are you sure you tested with an exact match? Remeber that .Match is case sensitive. :-)

#176394
Mar 17, 2017 15:19
Vote:
 

So the reason why it doesn't work is this:

The Match method is only for exact matches and the MatchContained does the same, but on complex objects. When using filter methods the content is not analyzed. Therefore it is not possible to filter on tokens inside the fields.

I used your approach instead. Thanks, PM ;)

#176562
Mar 21, 2017 19:19
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.