Sha256: 01841490096c6c245350aca8f389bb02cf31ffd30d257a98653577e3be139a1d

Contents?: true

Size: 1.07 KB

Versions: 21

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

21 entries across 21 versions & 2 rubygems

Version Path
blacklight-8.6.1 lib/blacklight/solr/document.rb
blacklight-8.6.0 lib/blacklight/solr/document.rb
blacklight-8.5.1 lib/blacklight/solr/document.rb
blacklight-8.5.0 lib/blacklight/solr/document.rb
blacklight-8.4.0 lib/blacklight/solr/document.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/lib/blacklight/solr/document.rb
blacklight-8.3.0 lib/blacklight/solr/document.rb
blacklight-8.2.2 lib/blacklight/solr/document.rb
blacklight-8.2.1 lib/blacklight/solr/document.rb
blacklight-8.2.0 lib/blacklight/solr/document.rb
blacklight-8.1.0 lib/blacklight/solr/document.rb
blacklight-8.0.1 lib/blacklight/solr/document.rb
blacklight-8.0.0 lib/blacklight/solr/document.rb
blacklight-8.0.0.beta8 lib/blacklight/solr/document.rb
blacklight-8.0.0.beta7 lib/blacklight/solr/document.rb
blacklight-8.0.0.beta6 lib/blacklight/solr/document.rb
blacklight-8.0.0.beta5 lib/blacklight/solr/document.rb
blacklight-8.0.0.beta4 lib/blacklight/solr/document.rb
blacklight-8.0.0.beta3 lib/blacklight/solr/document.rb
blacklight-8.0.0.beta2 lib/blacklight/solr/document.rb