Module: Blacklight::Solr::Document

Extended by:
ActiveSupport::Concern
Includes:
Document, Document::ActiveModelShim, MoreLikeThis
Included in:
SolrDocument
Defined in:
app/models/concerns/blacklight/solr/document.rb

Defined Under Namespace

Modules: MoreLikeThis

Instance Attribute Summary

Attributes included from Document

#_source, #response

Instance Method Summary collapse

Methods included from MoreLikeThis

#more_like_this

Methods included from Document::ActiveModelShim

#[], #_read_attribute, #as_json, #destroyed?, #id, #marked_for_destruction?, #new_record?, #persisted?, #to_partial_path

Methods included from Document

#fetch, #first, #has?, #initialize, #method_missing, #more_like_this, #respond_to_missing?, #to_partial_path

Methods included from Document::Export

#export_as, #export_formats, #exports_as?, #will_export_as

Methods included from Document::CacheKey

#cache_key, #cache_version_key

Methods included from Document::SemanticFields

#to_semantic_values

Methods included from Document::SchemaOrg

#itemtype

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Blacklight::Document

Instance Method Details

#has_highlight_field?(k) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'app/models/concerns/blacklight/solr/document.rb', line 26

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

#highlight_field(k) ⇒ Object



32
33
34
# File 'app/models/concerns/blacklight/solr/document.rb', line 32

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