Sha256: a90dfa271bd4c29e2a0afb52caaafb129aeea1672475ed7a2e22b26ae820abb1

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

require 'active_support/concern'

module Georgia
  module Indexer
    class TireAdapter
      module CkeditorAssetExtension

        extend ActiveSupport::Concern

        included do

          include ::Tire::Model::Search
          include ::Tire::Model::Callbacks

          mapping do
            indexes :id,           :index    => :not_analyzed
            indexes :filename
            indexes :tags
            indexes :extension
            indexes :updated_at, :type => 'date'
          end

          def self.search model, params
            model.tire.search(page: (params[:page] || 1), per_page: (params[:per] || 8)) do
              if params[:query].present?
                query do
                  boolean do
                    must { string params[:query], default_operator: "AND" }
                  end
                end
                sort { by (params[:o] || :updated_at), (params[:dir] || :desc) }
              end
            end.results
          end

        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
georgia-0.7.6 lib/georgia/indexer/extensions/tire_adapter/ckeditor_asset.rb
georgia-0.7.5 lib/georgia/indexer/extensions/tire_adapter/ckeditor_asset.rb
georgia-0.7.4 lib/georgia/indexer/extensions/tire_adapter/ckeditor_asset.rb