Sha256: fdf9ffca4cb75814d08bee39d087bd23f96970c55e894e3acaaf7a8216caf716

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Georgia
  module Indexer
    module Tire
      module Ckeditor
        module Asset
          def self.extended(base)
            base.class_eval 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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.7.3 lib/georgia/indexer/tire/ckeditor/asset.rb