コード例 #1
0
ファイル: SuggestDescriptor.cs プロジェクト: GopiKand/NEST
        /// <summary>
        /// The completion suggester is a so-called prefix suggester.
        /// It does not do spell correction like the term or phrase suggesters but allows basic auto-complete functionality.
        /// </summary>
        public SuggestDescriptor <T> Completion(string name, Func <CompletionSuggestDescriptor <T>, CompletionSuggestDescriptor <T> > suggest)
        {
            name.ThrowIfNullOrEmpty("name");
            suggest.ThrowIfNull("suggest");

            var desc = new CompletionSuggestDescriptor <T>();
            var item = suggest(desc);

            Self.Suggest.Add(name, item);
            return(this);
        }
コード例 #2
0
        /// <summary>
        /// The completion suggester is a so-called prefix suggester.
        /// It does not do spell correction like the term or phrase suggesters but allows basic auto-complete functionality.
        /// </summary>
        public SearchDescriptor <T> SuggestCompletion(string name, Func <CompletionSuggestDescriptor <T>, CompletionSuggestDescriptor <T> > suggest)
        {
            name.ThrowIfNullOrEmpty("name");
            suggest.ThrowIfNull("suggest");
            if (this._Suggest == null)
            {
                this._Suggest = new Dictionary <string, object>();
            }

            var desc   = new CompletionSuggestDescriptor <T>();
            var item   = suggest(desc);
            var bucket = new SuggestDescriptorBucket <T> {
                _Text = item._Text, CompletionSuggest = item
            };

            this._Suggest.Add(name, bucket);
            return(this);
        }
コード例 #3
0
ファイル: SearchDescriptor.cs プロジェクト: GopiKand/NEST
        /// <summary>
        /// The completion suggester is a so-called prefix suggester.
        /// It does not do spell correction like the term or phrase suggesters but allows basic auto-complete functionality.
        /// </summary>
        public SearchDescriptor <T> SuggestCompletion(string name, Func <CompletionSuggestDescriptor <T>, CompletionSuggestDescriptor <T> > suggest)
        {
            name.ThrowIfNullOrEmpty("name");
            suggest.ThrowIfNull("suggest");
            if (Self.Suggest == null)
            {
                Self.Suggest = new Dictionary <string, ISuggestBucket>();
            }

            var desc = new CompletionSuggestDescriptor <T>();
            var item = suggest(desc);
            ICompletionSuggester i = item;
            var bucket             = new SuggestBucket {
                Text = i.Text, Completion = item
            };

            Self.Suggest.Add(name, bucket);
            return(this);
        }