/// <summary> /// Run a quoted query /// </summary> /// <returns></returns> public ISearchResults ResultsAsEntered() { var query = new StringBuilder(); query.Append(this.QueryAllPropertiesAnd(SearchUtilities.GetSearchTermQuoted(this.Parameters.SearchTerm), 1.0)); return(this.ExecuteSearch(this.WrapQuery(query))); }
/// <summary> /// Execute a search requiring all terms in the query to be present, not necessarily in /// the order entered, though that will boost the relevance. Pretty much the same /// as SearchMultiRelevance, except terms are AND'd rather than OR'd /// </summary> /// <returns></returns> public ISearchResults ResultsMultiAnd() { var query = new StringBuilder(); if (this.Parameters.SearchTerm.Contains('"')) { // If the user has entered double quotes we don't bother // searching for the full string query.Append(this.QueryAllPropertiesAnd(SearchUtilities.GetSearchTermsSplit(this.Parameters.SearchTerm), 1.0)); } else if (!this.Parameters.SearchTerm.Contains('"') && !this.Parameters.SearchTerm.Contains(' ')) { // if there's no spaces or quotes we don't need to get the quoted term and boost it query.Append(this.QueryAllPropertiesAnd(SearchUtilities.GetSearchTermsSplit(this.Parameters.SearchTerm), 1)); } else { // otherwise we search first for the entire query in quotes, // then for each term in the query OR'd together. query.AppendFormat("{0} OR {1}", this.QueryAllPropertiesAnd(SearchUtilities.GetSearchTermQuoted(this.Parameters.SearchTerm), 2) , this.QueryAllPropertiesAnd(SearchUtilities.GetSearchTermsSplit(this.Parameters.SearchTerm), 1) ); } return(this.ExecuteSearch(this.WrapQuery(query))); }
/// <summary> /// Simple search for any term in the query. Make this simpler so it executes faster /// </summary> /// <returns></returns> public ISearchResults ResultsSimpleOr() { var query = new StringBuilder(); query.Append(this.QueryAllProperties(SearchUtilities.GetSearchTermsSplit(this.Parameters.SearchTerm), 1.0, "OR", true)); return(this.ExecuteSearch(this.WrapQuery(query))); }