public static ITypeSearch <T> Filter <T>(this ITypeSearch <T> query, IFilterStatementRequest request) where T : IContent { if (request?.Filters?.Items == null) { return(query); } var filterBuilder = ClientExtensions.BuildFilter <T>(SearchClient.Instance); filterBuilder = request.Filters.Items.Aggregate(filterBuilder, (builder, item) => { if (item.Connector == FilterStatementConnector.And) { return(builder.And(GetExpression <T>(item))); } else { var expression = GetExpression <T>(item); if (expression == null) { expression = GetExpression <T>(item); } return(expression == null ? builder : builder.Or(expression)); } }); if (filterBuilder.HasFilter) { query = TypeSearchExtensions.Filter(query, filterBuilder); } return(query); }