Increase Search Results

function increase_search_results($query) {
    if ($query->is_search) {
        $query->set('posts_per_page', '50');
    }
    return $query;
}
add_filter('pre_get_posts', 'increase_search_results');