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.15.2 app/models/krikri/search_index_document.rb
krikri-0.15.1 app/models/krikri/search_index_document.rb
krikri-0.15.0 app/models/krikri/search_index_document.rb
krikri-0.14.0 app/models/krikri/search_index_document.rb
krikri-0.13.2 app/models/krikri/search_index_document.rb
krikri-0.13.1 app/models/krikri/search_index_document.rb
krikri-0.13.0 app/models/krikri/search_index_document.rb
krikri-0.12.4 app/models/krikri/search_index_document.rb
krikri-0.12.3 app/models/krikri/search_index_document.rb
krikri-0.12.1 app/models/krikri/search_index_document.rb
krikri-0.12.0 app/models/krikri/search_index_document.rb
krikri-0.12.0.pre.rc.1 app/models/krikri/search_index_document.rb
krikri-0.11.2 app/models/krikri/search_index_document.rb
krikri-0.11.1 app/models/krikri/search_index_document.rb
krikri-0.11.0 app/models/krikri/search_index_document.rb
krikri-0.10.1 app/models/krikri/search_index_document.rb
krikri-0.10.0 app/models/krikri/search_index_document.rb
krikri-0.9.0 app/models/krikri/search_index_document.rb
krikri-0.8.9 app/models/krikri/search_index_document.rb
krikri-0.8.8 app/models/krikri/search_index_document.rb