예제 #1
0
        /// <summary>
        /// The term suggester suggests terms based on edit distance. The provided suggest text is analyzed before terms are suggested.
        /// The suggested terms are provided per analyzed suggest text token. The term suggester doesn’t take the query into account that is part of request.
        /// </summary>
        public SuggestDescriptor <T> Term(string name, Func <TermSuggesterDescriptor <T>, TermSuggesterDescriptor <T> > suggest)
        {
            name.ThrowIfNullOrEmpty(nameof(name));
            suggest.ThrowIfNull(nameof(suggest));
            var desc = new TermSuggesterDescriptor <T>();
            var item = suggest(desc);

            Self.Suggest.Add(name, item);
            return(this);
        }
예제 #2
0
 /// <summary>
 /// The term suggester suggests terms based on edit distance. The provided suggest text is analyzed before terms are suggested.
 /// The suggested terms are provided per analyzed suggest text token. The term suggester doesn’t take the query into account that is part of request.
 /// </summary>
 public SearchDescriptor <T> SuggestTerm(string name, Func <TermSuggesterDescriptor <T>, TermSuggesterDescriptor <T> > suggest) => Assign(a =>
 {
     name.ThrowIfNullOrEmpty(nameof(name));
     suggest.ThrowIfNull(nameof(suggest));
     if (a.Suggest == null)
     {
         a.Suggest = new Dictionary <string, ISuggestBucket>();
     }
     var desc         = new TermSuggesterDescriptor <T>();
     var item         = suggest(desc);
     ITermSuggester i = item;
     var bucket       = new SuggestBucket {
         Text = i.Text, Term = item
     };
     a.Suggest.Add(name, bucket);
 });