<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def apply_published_filter(self, queryset, operation, value):
 """ Add the appropriate Published filter to a given elasticsearch query. :param queryset: The DJES queryset object to be filtered. :param operation: The type of filter (before/after). :param value: The date or datetime value being applied to the filter. """

        if operation not in ["after", "before"]:
            raise ValueError("""Publish filters only use before or after for range filters.""")
        return queryset.filter(Published(**{operation: value}))