_tommadden
09/08/2024, 7:36 AMSteven (he/him)
09/08/2024, 11:14 AMIContentIndexHandlerusing Umbraco.Cms.Core.DeliveryApi;
namespace Umbraco.Docs.Samples;
public class ContentTypesFilter : IFilterHandler
{
    private const string ContentTypesSpecifier = "contentTypes:";
    private const string FieldName = "contentType";
    // Querying
    public bool CanHandle(string query)
        => query.StartsWith(ContentTypesSpecifier, StringComparison.OrdinalIgnoreCase);
    public FilterOption BuildFilterOption(string filter)
    {
        var fieldValue = filter.Substring(ContentTypesSpecifier.Length);
        // There might be several values for the filter
        var values = fieldValue.Split(',');
        return new FilterOption
        {
            FieldName = FieldName,
            Values = values,
            Operator = FilterOperation.Is
        };
    }
}/umbraco/delivery/api/v2/content?filter=contentTypes:blog,blogPostSteven (he/him)
09/08/2024, 11:15 AMBjarne Fyrstenborg
01/09/2025, 8:43 AM