Check If search query contains something?

After the question’s update, I think that you need to set the canonical URL:

add_action( 'wp_head', 'cyb_search_results_canonical_URL' );
function cyb_search_results_canonical_URL() {
    if( is_search() ) {
        $link = get_search_link();
        echo '<link rel="canonical" href="' . esc_url( $link ) . '">';
    }
}

And your problem with duplicated content is fixed.