Restricting wordpress search only for specific post type

function search_filter($query) {
    if ($query->is_search) {
        $query->set('post_type', 'post');  // specify slug of post type instead of this 'post'
    }
    return $query;
}
add_filter('pre_get_posts','search_filter');