def METHOD_NAME(request, query):
    params = search_string_to_params(query)
    normalized = params_to_search_string(params)
    main_search = MainappSearch(params, limit=settings.SEARCH_PAGINATION_LENGTH)
    for error in main_search.errors:
        messages.error(request, error)
    try:
        handle_subscribe_requests(
            request,
            params,
            _("You will now receive notifications about new search results."),
            _("You will no longer receive notifications."),
            _("You have already subscribed to this search."),
        )
    except NeedsLoginError as err:
        return redirect(err.redirect_url)
    executed = main_search.execute()
    results = [parse_hit(hit) for hit in executed.hits]
    context = _search_to_context(normalized, main_search, executed, results, request)
    context["new_facets"] = aggs_to_context(executed)
    return render(request, "mainapp/search/search.html", context)