Sha256: 83c7ea7769c534c40f86dc8ecf909d899f1bb019c5c43088352aa2684ec07c6a
Contents?: true
Size: 973 Bytes
Versions: 3
Compression:
Stored size: 973 Bytes
Contents
# frozen_string_literal: true module SpeedyAF module IndexedContent extend ActiveSupport::Concern MAX_CONTENT_SIZE = 8192 included do after_save :update_external_index end def to_solr(solr_doc = {}, opts = {}) return solr_doc unless opts[:external_index] solr_doc.tap do |doc| doc[:id] = id doc[:has_model_ssim] = self.class.name doc[:uri_ss] = uri.to_s doc[:mime_type_ss] = mime_type doc[:original_name_ss] = original_name doc[:size_is] = content.present? ? content.size : 0 doc[:'empty?_bs'] = content.blank? doc[:content_ss] = content if index_content? end end def update_external_index ActiveFedora::SolrService.add(to_solr({}, external_index: true), softCommit: true) end protected def index_content? has_content? && mime_type =~ /(^text\/)|([\/\+]xml$)/ && size < MAX_CONTENT_SIZE && content !~ /\x00/ end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
speedy-af-0.4.0 | lib/speedy_af/indexed_content.rb |
speedy-af-0.3.0 | lib/speedy_af/indexed_content.rb |
speedy-af-0.2.0 | lib/speedy_af/indexed_content.rb |