Sha256: 9a6539f639a7bcaf8bf4c1ad779ff575ee3c7c8aa7026407c247fea25723a953

Contents?: true

Size: 858 Bytes

Versions: 45

Compression:

Stored size: 858 Bytes

Contents

module Krikri
  ##
  # Subclass of Blacklight's SolrDocument.
  # Represents a single document returned from a query to the search index.
  class SearchIndexDocument < SolrDocument

    ##
    # Use local name instead of full item id URI in route.  For example, a
    # document with the id 'http://dp.la/marmotta/ldp/items/123ab' will have an
    # id param of '123ab'.  This is necessary because routes that contain '.' 
    # are not valid.
    # @return String
    def to_param
      self[self.class.unique_key].match(/[\/]([^\/]*)\z/)[1]
    end

    ##
    # Get the aggregation, populated with data from Marmotta, which corresponds
    # to this SearchIndexDocument
    # @return [DPLA::MAP::Aggregation, nil]
    def aggregation
      agg = DPLA::MAP::Aggregation.new(id)
      return nil unless agg.exists?
      agg.get
      agg
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
krikri-0.5.3 app/models/krikri/search_index_document.rb
krikri-0.5.2 app/models/krikri/search_index_document.rb
krikri-0.5.1 app/models/krikri/search_index_document.rb
krikri-0.5.0 app/models/krikri/search_index_document.rb
krikri-0.4.0 app/models/krikri/search_index_document.rb