public IEnumerable <T> SearchSuppressionList(string q, SearchParameters p) { ISearchResponse <T> result; SearchDescriptor <T> descriptor = new SearchDescriptor <T>(); string Field = string.Empty; List <string> Indices = new List <string>(); Type type = p.Types.FirstOrDefault(); if (p != null && p.Types.FirstOrDefault() != null && type.Equals(typeof(SuppressedEmail))) { Field = "email"; Indices.Add("suppressedemails1"); if (p.AccountId != 1) { Indices.Add("suppressedemails" + p.AccountId); } } else if (p != null && p.Types.FirstOrDefault() != null && type.Equals(typeof(SuppressedDomain))) { Field = "domain"; Indices.Add("suppresseddomains1"); if (p.AccountId != 1) { Indices.Add("suppresseddomains" + p.AccountId); } } string regexValue = ".*" + q + ".*"; if (!string.IsNullOrEmpty(q)) { regexValue = ".*" + q.ToLower() + ".*"; } FilterContainer query = new FilterContainer(); FilterDescriptor <SuppressionList> filterDesc = new FilterDescriptor <SuppressionList>(); query = filterDesc.Regexp(rg => rg.OnField(Field).Value(regexValue)); descriptor = descriptor.Filter(fil => fil.Or(query)).Indices(Indices).Type(type.Name.ToLower() + "s"); result = ElasticClient().Search <T>(b => descriptor); string qu = result.ConnectionStatus.ToString(); Logger.Current.Informational(qu); return(result.Documents); }