Sha256: 6a41f0cab0998939f08c6751a2bbb314fe48530fd2535faca502f22edaf77563
Contents?: true
Size: 1.78 KB
Versions: 27
Compression:
Stored size: 1.78 KB
Contents
module Enjoy module Controllers module Search extend ActiveSupport::Concern # def index # if params[:query].blank? # @results = [] # else # @results = Mongoid::Elasticsearch.search({ # body: { # query: { # query_string: { # query: Mongoid::Elasticsearch::Utils.clean(params[:query]) # } # }, # highlight: { # fields: { # name: {}, # content: {} # } # } # }}, # page: params[:page], # per_page: Enjoy.configuration.search_per_page, # ) # end # end def index if params[:q].blank? @results = [] else query = params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip @results = Enjoy::Page.search(query, per_page: 10, highlight: true, suggest: true, page: params[:page], per_page: Enjoy.configuration.search_per_page ) # @results = Mongoid::Elasticsearch.search({ # body: { # query: { # query_string: { # query: Mongoid::Elasticsearch::Utils.clean(params[:query]) # } # }, # highlight: { # fields: { # name: {}, # content: {} # } # } # }}, # page: params[:page], # per_page: Enjoy.config.search_per_page, # ) end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems