/spree_like_all_searcher

Spree Extension that searches for terms that match all keywords in search

Primary LanguageRubyMIT LicenseMIT

SpreeLikeAllSearcher

By default, Spree searches for terms in a “Like Any” fashion. For example, if you searched for “2006 Mustang”, Spree would break this search in to an array

["2006", "Mustang"]

then it would find all products that have the word “2006” or “Mustang”. In some sites this may not be optimal, because you want to narrow the results down to include both terms.

The Spree Like All Searcher takes the array and will find either both terms in the Title or description, such that the generated where clause in the SQL looks like this:

(
  `spree_products`.name LIKE '%2006%' 
    AND `spree_products`.name LIKE '%Mustang%' 
    OR `spree_products`.description LIKE '%2006%' 
    AND `spree_products`.description LIKE '%Mustang%'
)

Installation

Add the following to your Gemfile

gem 'spree_like_all_searcher', :git => 'git@github.com:entropillc/spree_like_all_searcher.git'

Run bundle install, and you should be golden