public void InitializeControls(ISkinControlLoader controlLoader) { IEnumerable <string> controlNames = _controls; if (controlNames != null) { var apnlCommentsWrapper = new UpdatePanel { Visible = true, ID = CommentsPanelId }; if (!controlNames.Contains("HomePage", StringComparer.OrdinalIgnoreCase) && !String.IsNullOrEmpty(Query)) { int entryId = -1; Entry entry = Cacher.GetEntryFromRequest(true, SubtextContext); if (entry != null) { entryId = entry.Id; } var query = Query; if (!String.IsNullOrEmpty(query)) { var searchResults = SearchEngineService.Search(query, 5, Blog.Id, entryId); if (searchResults.Any()) { AddMoreResultsControl(searchResults, controlLoader, apnlCommentsWrapper); } } } foreach (string controlName in controlNames) { Control control = controlLoader.LoadControl(controlName); AddControlToBody(controlName, control, apnlCommentsWrapper, CenterBodyControl); } } }
protected override void OnLoad(EventArgs e) { int blogId = Blog.Id >= 1 ? Blog.Id : 0; var urlRelatedLinks = FindControl("Links") as Repeater; if (urlRelatedLinks != null) { if (SearchResults == null) { int entryId = -1; Entry entry = Cacher.GetEntryFromRequest(true, SubtextContext); if (entry != null) { entryId = entry.Id; } SearchResults = SearchEngineService.Search(Query, RowCount, blogId, entryId); } urlRelatedLinks.DataSource = SearchResults; urlRelatedLinks.DataBind(); } var keywords = FindControl("keywords") as Literal; if (keywords != null) { keywords.Text = HttpUtility.HtmlEncode(Query); } base.OnLoad(e); }
public void CanSearchByIntegerField() { CreateIndex(1); using (SearchEngineService ses = SearchEngineService.GetByCloset(1)) { SearchParameters sp = new SearchParameters(); sp.MyRating = 4; SearchEngineResponse ser = ses.Search(sp, 0, 10, "EditorRating", false); Assert.IsTrue(ser.TotalCount == 0, ser.TotalCount.ToString()); sp.MyRating = 5; ser = ses.Search(sp, 0, 10, "EditorRating", false); Assert.IsTrue(ser.TotalCount == 1, ser.TotalCount.ToString()); } }
public void CanSearchEventTypes() { CreateIndex(1); using (SearchEngineService ses = SearchEngineService.GetByCloset(1)) { SearchParameters sp = new SearchParameters(); sp.EventTypes = new[] { "Formal Affair Evening" }; SearchEngineResponse ser = ses.Search(sp, 0, 10, "EditorRating", false); Assert.IsTrue(ser.TotalCount > 0); } }
public void CanSearchAllSeasons() { CreateIndex(1); using (SearchEngineService ses = SearchEngineService.GetByCloset(1)) { SearchParameters sp = new SearchParameters(); sp.Seasons = new [] { "winter", "summer", "spring", "fall" }; SearchEngineResponse ser = ses.Search(sp, 0, 10, "EditorRating", false); Assert.IsTrue(ser.TotalCount == 100, ser.TotalCount.ToString()); } }
public void SearchEngineService_WithEntry_AddsToIndex() { _service.AddPost(new SearchEngineEntry { EntryId = 1, Body = "This is a sample post", Title = "This is the title", Tags = "Title", BlogName = "MyTestBlog", IsPublished = true, PublishDate = DateTime.Now, EntryName = "this-is-the-title" } ); _service.AddPost(new SearchEngineEntry { EntryId = 2, Body = "This is another sample post", Title = "This is another title", Tags = "Title another", BlogName = "MyTestBlog", IsPublished = true, PublishDate = DateTime.Now, EntryName = "this-is-the-title" } ); var result = _service.Search("sample", 100, 0) as List <SearchEngineResult>; Assert.AreEqual(2, result.Count); }
public void CanSearchFriendRateRange() { CreateIndex(1); using (SearchEngineService ses = SearchEngineService.GetByCloset(1)) { SearchParameters sp = new SearchParameters(); sp.IsRatedByFriends = true; SearchEngineResponse ser = ses.Search(sp, 0, 10, "EditorRating", false); Assert.IsTrue(ser.TotalCount == 11, ser.TotalCount.ToString()); Assert.IsTrue(ser.Results.Count() > 0); } }
public void GetIndex() { using (SearchEngineService ses = SearchEngineService.GetByCloset(98)) { SearchParameters sp = new SearchParameters(); sp.Seasons = new[] { "winter", "summer", "spring", "fall" }; SearchEngineResponse ser = ses.Search(sp, 0, 9, "EditorRating", false); Console.WriteLine(ser.TotalCount); foreach (SearchEngineResult res in ser.Results) { Console.WriteLine(res.EntryId); } } }
public void GetResult_validValue_ReturnsSearchFightResult() { //Arrange _bingApiResultServiceMockBuilder.WithBingGetSearchEngineMatch(); _googleApiResultServiceMockBuilder.WithGoogleGetSearchEngineMatch(); //Action var result = _service.Search(new List <string> { "query1", "query2" }); //Assert result.Should().NotBeNull(); }
public static void RunSearch(object closet) { using (SearchEngineService ses = SearchEngineService.GetByCloset(Convert.ToInt32(closet))) { SearchParameters sp = new SearchParameters(); sp.FreeText = ""; sp.IsRatedByMe = false; sp.FlavorId = 2; sp.IsRatedByFriends = true; SearchEngineResponse response = ses.Search(sp, 0, 10, "MyRating", true); Assert.IsTrue(response.TotalCount > 0); Console.WriteLine(response.TotalCount); }; }
public void CanUpdateIndex() { CreateIndex(1); using (SearchEngineService ses = SearchEngineService.GetByCloset(1)) { //int totalEntry = ses.GetTotalIndexedEntryCount(); //ses.RemovePost(2); //Assert.IsTrue(ses.GetTotalIndexedEntryCount() == totalEntry - 1); SearchEngineEntry see = new SearchEngineEntry(); see.EntryId = 2; int amountOfClothes = rnd.Next(10) + 1; see.Categories = GetRandom(categories, amountOfClothes / 2); see.Colors = GetRandom(colors, amountOfClothes); see.Silouhettes = GetRandom(silouhettes, amountOfClothes); see.EventTypes = GetRandom(eventTypes); see.Fabrics = GetRandom(fabrics); see.Seasons = GetRandom(seasons); see.Tags = GetRandom(tags); see.CreatedByMe = true; see.EditorRating = Convert.ToInt32(GetRandom(rating, 1)); see.FriendRating = Convert.ToInt32(GetRandom(rating, 1)); see.MyRating = 6; see.FlavorId = Convert.ToInt32(GetRandom(flavor, 1)); ses.AddEntry(see); //Assert.IsTrue(ses.GetTotalIndexedEntryCount() == totalEntry); SearchParameters sp = new SearchParameters(); //sp.CreatedByMe = true; sp.MyRating = 6; SearchEngineResponse ser = ses.Search(sp, 0, 10, "EditorRating", false); Assert.IsTrue(ser.TotalCount == 1); } }
protected override void OnLoad(EventArgs e) { if (IsPostBack) { return; } var searchResults = FindControl("results") as Repeater; var noResults = FindControl("noresults") as PlaceHolder; var terms = FindControl("terms") as Literal; var txtSearch = FindControl("txtSearch") as TextBox; string queryString = SubtextContext.RequestContext.GetQueryFromRequest(); if (!String.IsNullOrEmpty(queryString)) { if (txtSearch != null) { txtSearch.Text = queryString; } var results = SearchEngineService.Search(queryString, MaxResultsCount, Blog.Id); if (results.Count() > 0) { searchResults.DataSource = results; searchResults.DataBind(); searchResults.Visible = true; } else { terms.Text = HttpUtility.HtmlEncode(queryString); noResults.Visible = true; } } base.OnLoad(e); }
private IList <ClosetOutfitView> Search(out int totalCount, OutfitSearch outfitSearch, RegisteredUser user) { IList <ClosetOutfitView> result = new List <ClosetOutfitView>(); using (SearchEngineService ses = SearchEngineService.GetByCloset(user.Closet.Id)) { string sortBy = string.Empty; switch (outfitSearch.SortBy) { case "1": sortBy = "EditorRating"; break; case "2": sortBy = "MyRating"; break; case "3": sortBy = "FriendRating"; break; case "4": sortBy = "WornDate"; break; } SearchParameters sp = new SearchParameters(); if (outfitSearch.MyFavorites) { sp.MyRating = 5; } if (!string.IsNullOrEmpty(outfitSearch.Search)) { outfitSearch.Search = outfitSearch.Search.Replace(',', ' '); } if (!string.IsNullOrEmpty(outfitSearch.Color)) { outfitSearch.Color = outfitSearch.Color.Replace(',', ' '); } if (!string.IsNullOrEmpty(outfitSearch.Pattern)) { outfitSearch.Pattern = outfitSearch.Pattern.Replace(',', ' '); } sp.FreeText = string.Format("{0} {1} {2}", outfitSearch.Color, outfitSearch.Pattern, outfitSearch.Search); char[] separator = new char[1]; separator[0] = ' '; if (!string.IsNullOrEmpty(outfitSearch.SeasonName)) { sp.Seasons = outfitSearch.SeasonName.Split(separator, StringSplitOptions.RemoveEmptyEntries); } if (!string.IsNullOrEmpty(outfitSearch.Garment) && outfitSearch.Garment != NOCATEGORY) { sp.FreeText += " " + outfitSearch.Garment; } separator[0] = ','; if (!string.IsNullOrEmpty(outfitSearch.SelectedEvents)) { sp.EventTypes = outfitSearch.SelectedEvents.Split(separator, StringSplitOptions.RemoveEmptyEntries); } if (!string.IsNullOrEmpty(outfitSearch.Trend) && outfitSearch.Trend != NOTREND) { Trend trend = trendRepository.GetByName(outfitSearch.Trend); sp.TrendKeywords = new List <string>(trend.Keywords).ToArray(); } if (outfitSearch.CreatedByMe) { sp.CreatedByMe = true; } if (outfitSearch.IsRatedByMe) { sp.IsRatedByMe = true; } if (outfitSearch.IsRatedByFriends) { sp.IsRatedByFriends = true; } if (outfitSearch.IsUpToDate) { sp.IsUpToDate = true; } if (outfitSearch.SelectedFlavors != null && outfitSearch.SelectedFlavors.Split(separator, StringSplitOptions.RemoveEmptyEntries).Length == 1) { sp.FlavorId = Convert.ToInt32(outfitSearch.SelectedFlavors.Split(separator, StringSplitOptions.RemoveEmptyEntries)[0]); } SearchEngineResponse response = ses.Search( sp, (Convert.ToInt32(outfitSearch.Page) * Convert.ToInt32(outfitSearch.PageSize)) - Convert.ToInt32(outfitSearch.PageSize), Convert.ToInt32(outfitSearch.PageSize), sortBy, true); totalCount = response.TotalCount; List <int> lstIds = new List <int>(); foreach (SearchEngineResult engineResult in response.Results) { lstIds.Add(engineResult.EntryId); } if (lstIds.Count > 0) { result = closetOutfitRepository.Search(lstIds, user.Closet.Id); } } return(result); }