Skip to content

Commit

Permalink
Empty queries don't crash
Browse files Browse the repository at this point in the history
  • Loading branch information
bleroy committed Dec 27, 2011
1 parent ec15728 commit 4a53b73
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions App_Code/SearchHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public static void BuildIndex(HttpContext ctx) {
}

public static SearchResults Query(HttpContext ctx, string query, int page = 1) {
if (string.IsNullOrWhiteSpace(query)) {
return new SearchResults {
Documents = new SearchResult[0],
TotalCount = 0
};
}
var indexPath = ctx.Server.MapPath("~/App_Data/Index");
var indexSearcher = new DirectoryIndexSearcher(new DirectoryInfo(indexPath));
using (var searchService = new SearchService(indexSearcher)) {
Expand Down

0 comments on commit 4a53b73

Please sign in to comment.