Sha256: 3fdfc37d4209f6988eb9878d6799a84b3f29a1564d8f7af78ef801163330eaae

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 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.results
          end

        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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