def METHOD_NAME(self, user_input, request):
    total_count = 0
    projects = []
    # If we allow private projects,
    # we only search on projects the user belongs or have access to.
    if settings.ALLOW_PRIVATE_REPOS:
        projects = list(
            Project.objects.for_user(request.user).values_list("slug", flat=True)
        )
    # Make sure we always have projects to filter by if we allow private projects.
    if settings.ALLOW_PRIVATE_REPOS and not projects:
        results, facets = [], {}
    else:
        results, facets = self._search(
            user_input=user_input,
            projects=projects,
            use_advanced_query=True,
        )
        if results:
            total_count = results.hits.total["value"]
            results = ProjectSearchSerializer(results, many=True).data
    context = user_input._asdict()
    context.update(
        {
            "search_query": user_input.query,
            "results": results,
            "total_count": total_count,
            "facets": facets,
        }
    )
    return context