Sha256: 6f6b96b10d5c472dbfee24d51079f662491286fb98b65ec0791fdae821ba41e8

Contents?: true

Size: 1.07 KB

Versions: 74

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true
##
##
# = 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
  extend ActiveSupport::Concern
  include Blacklight::Document
  include Blacklight::Document::ActiveModelShim

  def more_like_this
    response.more_like(self).map { |doc| self.class.new(doc, response) }
  end

  def has_highlight_field? k
    return false if response['highlighting'].blank? || response['highlighting'][id].blank?

    response['highlighting'][id].key? k.to_s
  end

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

Version data entries

74 entries across 74 versions & 2 rubygems

Version Path
blacklight-7.40.0 lib/blacklight/solr/document.rb
blacklight-7.39.0 lib/blacklight/solr/document.rb
blacklight-7.38.0 lib/blacklight/solr/document.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/lib/blacklight/solr/document.rb
blacklight-7.37.0 lib/blacklight/solr/document.rb
blacklight-7.36.2 lib/blacklight/solr/document.rb
blacklight-7.36.1 lib/blacklight/solr/document.rb
blacklight-7.36.0 lib/blacklight/solr/document.rb
blacklight-7.35.0 lib/blacklight/solr/document.rb
blacklight-7.34.0 lib/blacklight/solr/document.rb
blacklight-7.33.1 lib/blacklight/solr/document.rb
blacklight-7.33.0 lib/blacklight/solr/document.rb
blacklight-7.32.0 lib/blacklight/solr/document.rb
blacklight-7.31.0 lib/blacklight/solr/document.rb
blacklight-7.30.0 lib/blacklight/solr/document.rb
blacklight-7.29.0 lib/blacklight/solr/document.rb
blacklight-7.28.0 lib/blacklight/solr/document.rb
blacklight-7.27.1 lib/blacklight/solr/document.rb
blacklight-7.27.0 lib/blacklight/solr/document.rb
blacklight-7.26.1 lib/blacklight/solr/document.rb