public static void ReformSearchCriteria(SimpleSearchCriteria criteria) { var specialTerms = GetSpecialTerms(criteria.SearchTerms); var terms = criteria.SearchTerms.Where(t => !t.StartsWith("\"") || !t.EndsWith("\"")). Select(t => t.NormalizeText()).Where(t => !String.IsNullOrWhiteSpace(t)). Distinct().ToList(); var originalTerms = terms.ToList(); var dictionarySplittedTerms = terms.SelectMany (ServiceLocator.Resolve <DictionaryBasedSplitter>(). ExtractWords).Where(t => t.Length >= TERM_MINIMUM_LENGTH).ToList(); terms.AddRange(dictionarySplittedTerms.Except(terms)); var queries = GetReformedQuery(terms.Distinct()).ToList(); if (queries.Count > 0) { LogEvents.AddSearchTermsToOriginal(queries.First()); var query = queries.First(); terms.AddRange(query.WordsAfterReform.Except(terms)); criteria.Explanation = GetExplanation(query, originalTerms); criteria.Reformed = true; criteria.RecommendedQueries = queries.GetRange(1, queries.Count - 1). Select(n => n.QueryString).AsQueryable(); if (queries.Count > 1) { LogEvents.IssueRecommendedQueries(queries.GetRange(1, queries.Count - 1). ToArray()); } } else { criteria.Explanation = String.Empty; criteria.Reformed = false; criteria.RecommendedQueries = Enumerable.Empty <String>().AsQueryable(); } terms.AddRange(specialTerms); criteria.SearchTerms = ConvertToSortedSet(terms); }