def build_facet_filter(self, view, filters=None):
        """
        Creates a dict of dictionaries suitable for passing to the
        SearchQuerySet ``facet``, ``date_facet`` or ``query_facet`` method.
        """

        field_facets = {}
        date_facets = {}
        query_facets = {}
        facet_serializer_cls = view.get_facet_serializer_class()

        if filters is None:
            filters = {}  # pragma: no cover

        if view.lookup_sep == ":":
            raise AttributeError("The %(cls)s.lookup_sep attribute conflicts with the HaystackFacetFilter "
                                 "query parameter parser. Please choose another `lookup_sep` attribute "
                                 "for %(cls)s." % {"cls": view.__class__.__name__})

        try:
            fields = getattr(facet_serializer_cls.Meta, "fields", [])
            exclude = getattr(facet_serializer_cls.Meta, "exclude", [])
            field_options = getattr(facet_serializer_cls.Meta, "field_options", {})

            for field, options in filters.items():

                if field not in fields or field in exclude:
                    continue

                field_options = merge_dict(field_options, {field: self.parse(view.lookup_sep, options)})

            valid_gap = ("year", "month", "day", "hour", "minute", "second")
            for field, options in field_options.items():
                if any([k in options for k in ("start_date", "end_date", "gap_by", "gap_amount")]):

                    if not all(("start_date", "end_date", "gap_by" in options)):
                        raise ValueError("Date faceting requires at least 'start_date', 'end_date' "
                                         "and 'gap_by' to be set.")

                    if not options["gap_by"] in valid_gap:
                        raise ValueError("The 'gap_by' parameter must be one of %s." % ", ".join(valid_gap))

                    options.setdefault("gap_amount", 1)
                    date_facets[field] = field_options[field]

                else:
                    field_facets[field] = field_options[field]

        except __HOLE__:
            raise ImproperlyConfigured("%s must implement a Meta class." %
                                       facet_serializer_cls.__class__.__name__)

        return {
            "date_facets": date_facets,
            "field_facets": field_facets,
            "query_facets": query_facets
        }
dataset/ETHPy150Open inonit/drf-haystack/drf_haystack/filters.py/HaystackFacetFilter.build_facet_filter