Wednesday, March 9, 2016

Sitecore Lucene boosting content of a specific template

When testing out my new Sitecore Lucene search engine, I noticed that for some key search terms, news articles were outranking the content pages (which should have been the highest matches). This was due to a high scoring based on keyword density in the news articles.

My solution for this was to boost the score for templates of the page type. This is achieved by including another predicate statement in my search logic that boosts templates of the page type (by 4.0f) along with an or statement with no boost for items not of those templates. This or statement is required otherwise items that weren't of the page type would not be included in the results - because we use and statements to join the outer predicates together.

As the above demo shows we join the main search predicate logic GetSearchPredicate with the template boosting predicate GetBoosterPredicate to create a single search predicate which will return the matching results.

As with any boosting/search logic it's important to thoroughly test to ensure the expected results are being returned across a range of search terms.

No comments:

Post a Comment