Skip to content

Instantly share code, notes, and snippets.

@mattgartman
Created September 6, 2014 16:15
Show Gist options
  • Save mattgartman/d92bd9621dff0f1cd704 to your computer and use it in GitHub Desktop.
Save mattgartman/d92bd9621dff0f1cd704 to your computer and use it in GitHub Desktop.
SolrDateBoost: Search Code
var indexName = string.Format("sitecore_{0}_index", Sitecore.Context.Database.Name);
var searchIndex = ContentSearchManager.GetIndex(indexName);
using (var context = searchIndex.CreateSearchContext())
{
var dateBoostPredicate = PredicateBuilder.True<SearchResultItemModel>();
dateBoostPredicate = dateBoostPredicate.And(x => x._val_ == "recip(ms(NOW, publicationdate_tdt), 3.16e-11, 1, 1)");
context.GetQueryable<SearchResultItemModel>()
.Where(result => result.Name.Contains("A"))
.Where(dateBoostPredicate)
.GetResults();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment