<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_search(queryset, search, schema=None):
 """ Applies search written in DjangoQL mini-language to given queryset """

    ast = DjangoQLParser().parse(search)
    schema = schema or DjangoQLSchema
    schema_instance = schema(queryset.model)
    schema_instance.validate(ast)
    return queryset.filter(build_filter(ast, schema_instance))