Finally figured out how to boost certain fields using Sitecore 7’s
ContentSearch LINQ provider. Boosting provides relevance enhancements when a
search term is found within a field. For example, a search term found in a
documents title
or keywords
field is probably way more relevant than if its
found in the body
.
You may have stumbled across the Boost
extension method but couldn’t get it
to work.
The issue is that the Boost
extension method does not work with the ==
operator: you have to use a method like .Equals
or .Matches
. (I think I’ll
throw up another post with the other provided LINQ operators).
So if you have a document type like BlogSearchResultItem
:
1 | using Sitecore.ContentSearch; |
You can boost the search term using Boost
:
1 | public SearchResults<BlogSearchResultItem> Search(string term) |
This should yield the following Lucene query:
1 | title:test^2.0 keywords:test^1.5 body:test |