Skip to content

Instantly share code, notes, and snippets.

@RyanABailey
Created February 29, 2016 20:10
Show Gist options
  • Select an option

  • Save RyanABailey/8b736bab18870bea66b8 to your computer and use it in GitHub Desktop.

Select an option

Save RyanABailey/8b736bab18870bea66b8 to your computer and use it in GitHub Desktop.
Lucene search code
public static Expression<Func<SearchModel, bool>> GetSearchPredicate(string searchTerm)
{
var predicate = PredicateBuilder.True<SearchModel>(); // Items which meet the predicate
// search logic cut down
predicate = predicate.Or(x => x.DispalyName.Like(searchTerm)).Boost(60);
// Only show items which are not excluded from search
predicate = predicate.And(x => x.ExcludeFromSearch == false);
return predicate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment