Geta / geta-optimizely-categories

An alternative to Optimizely's default category functionality, where categories are instead stored as localizable IContent.
5 stars 10 forks source link

[Change Request] Add an overload for ContentCategoriesFacet() which allows the definition of the TermsFacetRequest #25

Closed GeekInTheNorth closed 10 months ago

GeekInTheNorth commented 11 months ago

The current implementation of ContentCategoriesFacet() is nice in that it wraps up the facets for categories really nicely. However the default facet size is 10 and since this method does not take any other arguments, you cannot override the facet limit while using this method.

In order to facilitate my client's needs, I've have to look at what the ContentCategoriesFacet() method is doing in order to supply my own limit.

Work around:

var results = query.FilterForVisitor()
                   .Skip(request.From)
                   .Take(request.Take)
                   .OrderByDescending(x => x.StartPublish)
                   //.ContentCategoriesFacet()
                   .TermsFacetFor(x => x.Categories(), y => y.Size = 100 )
                   .GetContentResult();

Potential overloads options:

public static ITypeSearch<T> ContentCategoriesFacet<TSource>(this ITypeSearch<T> search, Action<TermsFacetRequest> facetRequestAction)

public static ITypeSearch<T> ContentCategoriesFacet<TSource>(this ITypeSearch<T> search, int size = 10)
frederikvig commented 10 months ago

Thanks for posting this. You can like you show very easily create your own extension methods for custom needs like this.