示例#1
0
        public void TestKeywords()
        {
            var criteria = new MemberSearchCriteria();

            criteria.SetKeywords("simple");
            AssertSuggestions(_memberSearchSuggestionsQuery.GetMoreResultsSuggestions(criteria), new KeywordsSuggestion());

            criteria.SetKeywords("software tester");
            var suggestedCriteria = new MemberSearchCriteria();

            suggestedCriteria.SetKeywords("software OR tester");
            AssertSuggestions(_memberSearchSuggestionsQuery.GetMoreResultsSuggestions(criteria), new KeywordsSuggestion(), new OrKeywordsSuggestion {
                Criteria = suggestedCriteria
            });
        }
示例#2
0
        private CandidateListRecoveryModel GetRecovery(CandidateListModel searchList)
        {
            const string method = "GetRecovery";

            try
            {
                // Get spelling suggestions if needed.

                var spellingSuggestions = searchList.Results.TotalCandidates <= Reference.SpellingThreshold
                    ? _memberSearchSuggestionsQuery.GetSpellingSuggestions(searchList.Criteria)
                    : null;

                // Get more results only if there are no spelling suggestions.

                var moreResultsSuggestions = searchList.Results.TotalCandidates <= Reference.MoreResultsThreshold && spellingSuggestions.IsNullOrEmpty()
                    ? _memberSearchSuggestionsQuery.GetMoreResultsSuggestions(searchList.Criteria)
                    : null;

                return(!spellingSuggestions.IsNullOrEmpty() || !moreResultsSuggestions.IsNullOrEmpty()
                    ? new CandidateListRecoveryModel {
                    SpellingSuggestions = spellingSuggestions, MoreResultsSuggestions = moreResultsSuggestions
                }
                    : null);
            }
            catch (Exception ex)
            {
                // Don't let a recovery failure cause the entire request to fail.

                EventSource.Raise(Event.Warning, method, "Cannot get the recovery for a search.", ex, new StandardErrorHandler());
                return(null);
            }
        }