Sha256: 9bec79b24762382c1aeeb79606efbff64d83c853ad9c9298e48fefd6662ed29d

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

# -*- encoding : utf-8 -*-
require 'rsolr'
##
##
# = Introduction
# Blacklight::Solr::Document is the module with logic for a class representing
# an individual document returned from Solr results.  It can be added in to any
# local class you want, but in default Blacklight a SolrDocument class is
# provided for you which is pretty much a blank class "include"ing
# Blacklight::Solr::Document.
#
# Blacklight::Solr::Document provides some DefaultFinders.
#
# It also provides support for Document Extensions, which advertise supported
# transformation formats.
#

module Blacklight::Solr::Document
  autoload :SchemaOrg, 'blacklight/solr/document/schema_org'
  autoload :DublinCore, 'blacklight/solr/document/dublin_core'
  autoload :Email, 'blacklight/solr/document/email'
  autoload :Sms, 'blacklight/solr/document/sms'
  autoload :Extensions, 'blacklight/solr/document/extensions'
  autoload :Export, 'blacklight/solr/document/export'
  autoload :MoreLikeThis, 'blacklight/solr/document/more_like_this'

  extend ActiveSupport::Concern
  include Blacklight::Document
  include Blacklight::Document::ActiveModelShim
  include Blacklight::Solr::Document::MoreLikeThis

  def has_highlight_field? k
    return false if response['highlighting'].blank? or response['highlighting'][self.id].blank?
    
    response['highlighting'][self.id].key? k.to_s
  end

  def highlight_field k
    response['highlighting'][self.id][k.to_s].map(&:html_safe) if has_highlight_field? k
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-6.0.0.pre3 app/models/concerns/blacklight/solr/document.rb
blacklight-6.0.0.pre2 app/models/concerns/blacklight/solr/document.rb
blacklight-6.0.0.pre1 app/models/concerns/blacklight/solr/document.rb
blacklight-5.15.0 lib/blacklight/solr/document.rb
blacklight-5.14.0 lib/blacklight/solr/document.rb
blacklight-5.13.1 lib/blacklight/solr/document.rb