Sha256: d941107a9894b137d502503dacf8d3e4567340d015a8bea7a8d1d266097ac11f

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'active_support/concern'

module Georgia
  module Indexer
    module SolrAdapter
      module CkeditorAssetExtension

        extend ActiveSupport::Concern

        included do

          searchable do
            text :filename, stored: true
            text :tags do
              tag_list.join(', ')
            end
            string :tags, stored: true, multiple: true do
              tag_list
            end
            string :extension, stored: true do
              extension.try(:downcase)
            end
            time :updated_at
            integer :size, stored: true do
              size / 1024 # gives size in KB
            end
          end

          def self.search_index model, params
            @search = model.search do
              fulltext params[:query] do
                fields(:filename, :tags)
              end
              with(:extension, params[:e]) unless params[:e].blank?
              with(:tags).any_of(params[:tg]) unless params[:tg].blank?
              order_by (params[:o] || :updated_at), (params[:dir] || :desc)
              paginate(page: params[:page], per_page: (params[:per] || 8))
            end
          end

        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.7.8 lib/georgia/indexer/extensions/solr_adapter/ckeditor/asset.rb