本文整理汇总了C#中ISearchService.Search方法的典型用法代码示例。如果您正苦于以下问题:C# ISearchService.Search方法的具体用法?C# ISearchService.Search怎么用?C# ISearchService.Search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISearchService
的用法示例。
在下文中一共展示了ISearchService.Search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchModule
public SearchModule (ISearchService<BlogPost> searchService, IBlogService blogService) : base(blogService)
{
Get["/search"] = p =>
{
var query = this.Bind<SearchQuery>();
var result = searchService.Search(query.Query, query.Page, 5);
ViewBag.SearchQuery = query.Query;
return View["Index", result];
};
}
示例2: GetResultsFromSearchService
public static async Task<IQueryable<Package>> GetResultsFromSearchService(ISearchService searchService, SearchFilter searchFilter)
{
var result = await searchService.Search(searchFilter);
// For count queries, we can ask the SearchService to not filter the source results. This would avoid hitting the database and consequently make
// it very fast.
if (searchFilter.CountOnly)
{
// At this point, we already know what the total count is. We can have it return this value very quickly without doing any SQL.
return result.Data.InterceptWith(new CountInterceptor(result.Hits));
}
// For relevance search, Lucene returns us a paged\sorted list. OData tries to apply default ordering and Take \ Skip on top of this.
// We avoid it by yanking these expressions out of out the tree.
return result.Data.InterceptWith(new DisregardODataInterceptor());
}
示例3: GetResultsFromSearchService
private static async Task<IQueryable<Package>> GetResultsFromSearchService(ISearchService searchService, SearchFilter searchFilter)
{
var result = await searchService.Search(searchFilter);
return FormatResults(searchFilter, result);
}