Sha256: be6127d3c5345cb7ef89e6ae51dbab85fd8b5bbe118847ddce5a6669b9e11d73

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 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::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
    return nil unless has_highlight_field? k
    response['highlighting'][self.id][k.to_s].map { |x| x.html_safe }
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-5.11.3 lib/blacklight/solr/document.rb
blacklight-5.12.0 lib/blacklight/solr/document.rb
blacklight-5.10.3 lib/blacklight/solr/document.rb
blacklight-5.11.2 lib/blacklight/solr/document.rb
blacklight-5.11.1 lib/blacklight/solr/document.rb
blacklight-5.11.0 lib/blacklight/solr/document.rb
blacklight-5.10.2 lib/blacklight/solr/document.rb
blacklight-5.10.1 lib/blacklight/solr/document.rb
blacklight-5.10.0 lib/blacklight/solr/document.rb