public static SearchQuery FirstPageQuery(string textToFind) { SearchQuery query = new SearchQuery(); query.PageIndex = 0; query.PageSize = 20; query.SearchTerms = textToFind; return query; }
/// <summary> /// Returns the results of a searchr request /// </summary> /// <param name="query"></param> /// <returns></returns> public virtual SearchResultSet GetSearchResults(SearchQuery query) { query.SectionsToFilter = GetPermissionFilterList(); SearchTerms st = GetSearchTerms(query); if(query.IsValid(st)) return GetSearchResults(query,GetSearchTerms(query)); else return new SearchResultSet(); }
protected abstract SearchResultSet GetSearchResults(SearchQuery query, SearchTerms terms);
protected static SearchTerms GetSearchTerms(SearchQuery query) { SearchTerms st = new SearchTerms(); ArrayList searchKeywords; //bool performLikeMatch = false; // Never Used string[] andTerms; string[] orTerms; // Clean the search terms // string searchTerms = Regex.Replace(query.SearchTerms, "[^\\w]", " ", RegexOptions.Compiled | RegexOptions.Multiline); // Added by [email protected] bool toHashcode = (SiteSettingsManager.GetSiteSettings().SearchMode == SearchMode.ForumsIndexer); searchKeywords = TokenizeKeywords(searchTerms, toHashcode); /* Commented by [email protected] // Tokenize the search terms and determine if we need to perform partial match // if (searchTerms.IndexOf("*") != 0) { //performLikeMatch = false; searchKeywords = TokenizeKeywords(searchTerms, true); } else { //performLikeMatch = true; searchKeywords = TokenizeKeywords(searchTerms, false); } */ // Do we have users that we are searching for? // // if ((usersToSearch[0] == "") || (usersToSearch[0] == "0")) // usersToSearch = null; // If we don't have any results // // if ((searchKeywords.Count == 0) && (query.UsersToSearch == null)) // throw new CSException(CSExceptionType.SearchNoResults); // Get the terms divided into and/or sets // // Modified by [email protected] // add "toHashcode" parameter GetAndOrKeywords (searchKeywords, toHashcode, out andTerms, out orTerms); st.And = andTerms; st.Or = orTerms; return st; }