<commit_before>module Spree
  module Search
    class Elasticsearch < Spree::Core::Search::Base
      def retrieve_products
        @products_scope = get_base_scope
        curr_page = page || 1

        if keywords.nil?
          @products = @products_scope.includes([:master => :prices])
        end
        if !@products.nil?
          unless Spree::Config.show_products_without_price
            @products = @products.where("spree_prices.amount IS NOT NULL").where("spree_prices.currency" => Spree::Config[:presentation_currency] || current_currency)
          end
        end
        if keywords.nil?
          @products = @products.page(curr_page).per(per_page)
        else
          @products = @products_scope.page(curr_page).per(per_page).records
        end
        @products
      end

       protected
         def get_base_scope
           if keywords.nil?
             base_scope = Spree::Product.active
             base_scope = base_scope.in_taxon(taxon) unless taxon.blank?
             base_scope = add_search_scopes(base_scope)
             base_scope = base_scope.descend_by_created_at
             base_scope
           else
             elasticsearch_query = build_es_query
             base_scope = Spree::Product.es_search(elasticsearch_query)
             base_scope
           end
         end

         def build_es_query
           query = {
             "query" => {
               "query_string" => {<commit_msg>products without images will not be displayed<commit_after>module Spree
  module Search
    class Elasticsearch < Spree::Core::Search::Base
      def retrieve_products
        @products_scope = get_base_scope
        curr_page = page || 1

        if keywords.nil?
          @products = @products_scope.includes([:master => :prices])
        end
        if !@products.nil?
          unless Spree::Config.show_products_without_price
            @products = @products.where("spree_prices.amount IS NOT NULL").where("spree_prices.currency" => Spree::Config[:presentation_currency] || current_currency)
          end
          @products = @products.select { |product| product.images.lengh > 0 }
        end
        if keywords.nil?
          @products = @products.page(curr_page).per(per_page)
        else
          @products = @products_scope.page(curr_page).per(per_page).records
        end
        @products
      end

       protected
         def get_base_scope
           if keywords.nil?
             base_scope = Spree::Product.active
             base_scope = base_scope.in_taxon(taxon) unless taxon.blank?
             base_scope = add_search_scopes(base_scope)
             base_scope = base_scope.descend_by_created_at
             base_scope
           else
             elasticsearch_query = build_es_query
             base_scope = Spree::Product.es_search(elasticsearch_query)
             base_scope
           end
         end

         def build_es_query
           query = {
             "query" => {
               "query_string" => {
{'fraction_non_alphanumeric': 0.08244325767690254, 'fraction_numerical': 0.0010013351134846463, 'mean_word_length': 1.988035892323031, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2116171', 'n_tokens_mistral': 824, 'n_tokens_neox': 817, 'n_words': 155}