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.37.1 lib/rocket_cms/controllers/search.rb
rocket_cms-0.37.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.36.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.35.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.34.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.33.1 lib/rocket_cms/controllers/search.rb
rocket_cms-0.33.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.32.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.31.1 lib/rocket_cms/controllers/search.rb
rocket_cms-0.31.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.30.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.29.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.28.0 lib/rocket_cms/controllers/search.rb
rocket_cms-0.27.8 lib/rocket_cms/controllers/search.rb
rocket_cms-0.27.7 lib/rocket_cms/controllers/search.rb
rocket_cms-0.27.6 lib/rocket_cms/controllers/search.rb
rocket_cms-0.27.5 lib/rocket_cms/controllers/search.rb
rocket_cms-0.27.4 lib/rocket_cms/controllers/search.rb
rocket_cms-0.27.3 lib/rocket_cms/controllers/search.rb
rocket_cms-0.27.2 lib/rocket_cms/controllers/search.rb