write codes imitate /gems/spree/core/lib/spree/core/search/base.rb