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

Version Path
enjoy_cms-0.3.7.4 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.7.3 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.7.2 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.7.1 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.7 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.6.2 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.6.1 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.6 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.5 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.4 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.3 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.2.1 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.2 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.1.2 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.1.1 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.1 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.0.4 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.0.3 lib/enjoy/controllers/search.rb
enjoy_cms-0.3.0.2 lib/enjoy/controllers/search.rb
enjoy_cms-0.2.1 lib/enjoy/controllers/search.rb