I produced custom page template.

<?php
/*
 * Template Name: foo
 */
?>

This file title is "foo.php".

I attempted

global $query_string;
query_posts($query_string . "&post_type=post");

But all pages is going to be excepted....

How you can exclude only this site template from wordpress search engine results?

Do this:

global $wp_query;
$args = array_merge($wp_query->query, array(
    'meta_query' => array(
        array(
            'key' => '_wp_page_template',
            'value' => 'foo.php',
            'compare' => '!='
        )
    ),
));
query_posts( $args );

Thanks Nikolay! For whatever reason last evening I simply wasn't getting this to operate however nowadays, to another hour or so, Used to do. It might have simply been the truth that I had been while using wrong filter or didn't have the final type of your code.

During my situation I needed to exclude content based on multiple templates, so, added more key/value/compare array elements. I additionally only wanted to get this done throughout searching, so, added a conditional clause for your. Here's the entire function I put into my theme's functions.php file:

// exclude any content from search results that use specific page templates
function exclude_page_templates_from_search($query) {

    global $wp_the_query;

    if ( ($wp_the_query === $query) && (is_search()) && ( ! is_admin()) ) {

        $args = array_merge($wp_the_query->query, array(
        'meta_query' => array(
            array(
                'key' => '_wp_page_template',
                'value' => 'page-template-1.php',
                'compare' => '!='
                ),
            array(
                'key' => '_wp_page_template',
                'value' => 'page-template-2.php',
                'compare' => '!='
                ),
            array(
                'key' => '_wp_page_template',
                'value' => 'page-template-3.php',
                'compare' => '!='
                )
            ),
        ));

        query_posts( $args );

    }

}
add_filter('pre_get_posts','exclude_page_templates_from_search');