Sha256: c27fe219a161cdc1d8e2a35181dfd55018f3896ffc0ea5e1c7cb0ff019549557

Contents?: true

Size: 1.17 KB

Versions: 74

Compression:

Stored size: 1.17 KB

Contents

module RocketCMS
  module Controllers
    module Search
      extend ActiveSupport::Concern
      def index
        if params[:query].blank?
          @results = []
        else
          if RocketCMS.mongoid?
            @results = Mongoid::Elasticsearch.search({
              body: {
                query: {
                  query_string: {
                    query: Mongoid::Elasticsearch::Utils.clean(params[:query])
                  }
                },
                highlight: {
                  require_field_match: false,
                  fields: {
                    name: {
                      number_of_fragments: 1,
                      size_of_fragments: 120
                    },
                    content: {
                      number_of_fragments: 1,
                      size_of_fragments: 220
                    }
                  }
                }
              }},
              page: params[:page],
              per_page: RocketCMS.config.search_per_page,
            )
          else
            @results = PgSearch.multisearch(params[:query]).page(params[:page]).per(RocketCMS.config.search_per_page)
          end
        end
      end
    end
  end
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
rocket_cms-0.14.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.13.6 lib/rocket_cms/controllers/search.rb
rocket_cms-0.13.5 lib/rocket_cms/controllers/search.rb
rocket_cms-0.13.4 lib/rocket_cms/controllers/search.rb
rocket_cms-0.13.3 lib/rocket_cms/controllers/search.rb
rocket_cms-0.13.2 lib/rocket_cms/controllers/search.rb
rocket_cms-0.13.1 lib/rocket_cms/controllers/search.rb
rocket_cms-0.13.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.12.3 lib/rocket_cms/controllers/search.rb
rocket_cms-0.12.2 lib/rocket_cms/controllers/search.rb
rocket_cms-0.12.1 lib/rocket_cms/controllers/search.rb
rocket_cms-0.12.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.11.7 lib/rocket_cms/controllers/search.rb
rocket_cms-0.11.5 lib/rocket_cms/controllers/search.rb