Boosting with filters


Ref, boosting documentation:

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()
                .BoostMatching(x => x.Heading.Match(query), 2)
                .BoostMatching(x => x.SubHeading.Match(query), 2)                

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

Mar 16, 2017 8:10

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. :-)

Mar 17, 2017 15:19

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 ;)

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.