So we have a recipe search page where an editor can choose e.g. christmas as the active category, and then we want all the recipes that are tagged with the category christmas to show up first.
I tried this:
var searchResult = findClient.Search<RecipePage>(Language.Norwegian).BoostMatching(x => x.TypeCategory.Match(activeCategory.ToString()), 1).GetContentResult();
But it doesn't seem to work. It gives the exact same result as if I don't boost. If I filter on the same category, I get the recipes I want:
var searchResult = findClient.Search<RecipePage>(Language.Norwegian).Filter(x => x.TypeCategory.Match(activeCategory.ToString())).GetContentResult();
What am I doing wrong? Is there a better way to solve this?
Can you try these suggestions for Match() method and see if that work? Also, have try in find boost UI to check if you are getting desired results?
Is your Episerver Find index contains the "Norwegian" language indexes?
If not then you can try by enabling the "Norwegian" language in Find or pass the "Language.None" in the query.
Your code looks fine, but your boost weighting isn't enough to boost the results you're matching on I think. The docs state:
"The default property weight, 1, does not affect the score. A weight above 1 boosts the score if the information is found in a corresponding property. A weight smaller than 1 reduces the score."
Change to 2 and see if that helps :)
It turned out to be what Paul suggested. I had misinterpreted the weighting, so I thought 1 was max. When I changed to 2, it worked.