Class: Workarea::Search::StorefrontSearch::ExactMatches
- Inherits:
-
Object
- Object
- Workarea::Search::StorefrontSearch::ExactMatches
- Includes:
- Middleware
- Defined in:
- app/queries/workarea/search/storefront_search/exact_matches.rb
Instance Method Summary collapse
- #call(response) ⇒ Object
- #find_exact_match(response) ⇒ Object
- #find_exact_matches(response) ⇒ Object
Methods included from Middleware
Instance Method Details
#call(response) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/queries/workarea/search/storefront_search/exact_matches.rb', line 7 def call(response) exact_match = find_exact_match(response) if response.customization.new_record? && !response.has_filters? && exact_match.present? response.redirect = product_path(exact_match) else yield end end |
#find_exact_match(response) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/queries/workarea/search/storefront_search/exact_matches.rb', line 17 def find_exact_match(response) exact_matches = find_exact_matches(response) # Depending on boost settings and configs, sometimes scores can exceed # the exact match threshold. Only render an exact match if it's a single match. return unless exact_matches.one? Elasticsearch::Serializer.deserialize(exact_matches.first['_source']) end |