public static SearchDescriptor <T> UpdateSearchDescriptor <T>(this SearchDescriptor <T> selector, Index index, SearchRequest request, string preAndPostTag) where T : class { // Validate parameters. if (selector == null) { throw new ArgumentNullException(nameof(selector)); } if (index == null) { throw new ArgumentNullException(nameof(index)); } if (string.IsNullOrWhiteSpace(preAndPostTag)) { throw new ArgumentNullException(nameof(preAndPostTag)); } request.Validate(); // Start updating. selector = selector. Index(Indices.Index(new [] { index.Name })). Type <T>(); // Set take, skip. if (request.Skip > 0) { selector = selector.Skip(request.Skip); } if (request.Take != null) { selector = selector.Size(request.Take.Value); } // Minimum score. if (request.MinimumScore != null) { selector = selector.MinScore((double)request.MinimumScore.Value); } // Query all of the fields. selector = selector.Query( q => q.Bool( b => b. Should(request.QueryStringQuery <T>()). Filter(request.Filter <T>()) ) ); // Highlight, if desired. if (request.Highlight) { // Highlight. selector = selector.Highlight( h => h .PreTags(preAndPostTag) .PostTags(preAndPostTag) .NumberOfFragments(0) .RequireFieldMatch(false) .Fields(f => f.Field("*")) ); } // Return the descriptor. return(selector); }