Sha256: d3118a06e8548956fc37ee8724b86b235a26b5da407c26b4f128a59f97d88630

Contents?: true

Size: 619 Bytes

Versions: 3

Compression:

Stored size: 619 Bytes

Contents

module Workarea
  module Search
    class StorefrontSearch
      class SpellingCorrectionWithContent < StorefrontSearch::SpellingCorrection
        def find_spell_correction(response)
          return nil if response.has_filters? || any_results?(response)

          product_correction = response.query.query_suggestions.first
          content_correction = response.content_query.query_suggestions.first

          product_correction.presence || content_correction
        end

        def any_results?(response)
          response.total > 0 || response.content_query.total > 0
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-content_search-1.1.0 app/queries/workarea/search/storefront_search/spelling_correction_with_content.rb
workarea-content_search-1.0.9 app/queries/workarea/search/storefront_search/spelling_correction_with_content.rb
workarea-content_search-1.0.8 app/queries/workarea/search/storefront_search/spelling_correction_with_content.rb