Hide certain products from Search Results page but keep on collection page

Hello,

I’m looking to hide a certain product collection (all products from that collection) from the search results page. But I want to keep these on the actual collection page. So customers if they go to the collection page they can see the products but if they search for them they don’t show.

This is because we have duplicate products, but the ones I want to hide our used ones.

Below is my code:

{% assign search_pagination = settings.pagination_limit %}
{% paginate search.results by search_pagination %}

  # {{ 'general.search.title' | t }}
  {% if search.performed %}
    
      - {{ 'general.search.results_count' | t: count: search.results_count }}
      
    

  {% endif %}

{% if search.performed %} 

  {% if search.results == empty %}
    

    

    

      

{{ 'general.search.no_results_html' | t: terms: search.terms|replace:'*','' }}

    

    

    

  {% else %}

 {% if settings.search_option == 'everything' or search.results.first.price == blank %}

  {% if settings.collection_sidebar %}
    {% include 'sidebar' %}
    

  {% else %}
    

  {% endif %}

    {% for item in search.results %}
      {% include 'easylockdown_filter_search' with item %}
      
      

        {% assign featured_image = false %}
        
        {% if item.object_type == 'article' and item.image %}
          {% assign featured_image = true %}
          

             
                
             
          

        {% elsif item.featured_image %}
          {% assign featured_image = true %}
          
             
                
             
          

       
        {% endif %}
        

        {% if settings.collection_sidebar %}
          
        {% else %}
          

        {% endif %}

          ##### 
            {{ item.title }}
          

          {% if item.price %}
             
                
                  {% if item.compare_at_price_max > item.price %}
                    {{ item.compare_at_price_max | money }}
                  {% endif %}

                  {% if item.available %}
                    {% if item.price_varies %}
                      {% if item.compare_at_price_max > item.price %}
                        

                      {% endif %}
                      <small>*{{ 'products.general.from' | t }}*</small>
                    {% endif %}
                    {{ item.price_min | money }}
                  {% else %}
                    {{ item.price_min | money }} - {{ 'products.product.sold_out' | t }}
                  {% endif %}
                
            

          {% endif %}

          {% if item.object_type == 'article' %}
            

              {% if settings.blog_author %}
                {{ 'blogs.article.by_author' | t: author: item.author }}
              {% endif %}

              {% if settings.blog_date %}
                {{ item.published_at | date: format: "month_day_year" }}
              {% endif %}
            

          {% endif %}

          {% if item.excerpt %}
            {{ item.excerpt }}

            {% if settings.read_more_link %}
              

                {{ 'blogs.general.continue_reading_html' | t }}
              

            {% endif %}
          {% else %}
            

              {{ item.content | strip_html | truncatewords: 40 | highlight: search.terms|replace:'*','' | replace: 'Description', '' | replace: 'Specs', '' | replace: 'Shipping', '' | replace: 'Size', '' }}
            

          {% endif %}
        

      

    

---

   {% endfor %}
  

 {% else %}
      {% if settings.collection_sidebar %}
        {% include 'sidebar' %}
        
      {% else %}
        

      {% endif %}

      {% assign products = search.results %}
      {% assign products_per_row = settings.products_per_row %}
      {% include 'product-loop' with settings.collection_sidebar %}

      

    {% endif %}
  {% endif %}

  {% include 'pagination' %}

{% else %}
  
    

    

    

      

        {{ 'general.search.description' | t }}
      

    

      
    

  

{% endif %}
{% endpaginate %}
      
      
      

This is called merchandising. You may not need coding skill if you use this app https://apps.shopify.com/ultimate-search-and-filter-1. It allows you to set Merchandising rules for your search results.