Module: Spotlight::SolrDocument::ClassMethods

Defined in:
app/models/concerns/spotlight/solr_document.rb

Overview

Class-level methods

Instance Method Summary collapse

Instance Method Details

#build_for_exhibit(id, exhibit, attributes = {}) ⇒ Object



19
20
21
22
23
# File 'app/models/concerns/spotlight/solr_document.rb', line 19

def build_for_exhibit(id, exhibit, attributes = {})
  new(unique_key => id).tap do |doc|
    doc.sidecar(exhibit).tap { |x| x.assign_attributes(attributes) }.save! # save is a nop if the sidecar isn't modified.
  end
end

#exhibit_slug_fieldObject



35
36
37
# File 'app/models/concerns/spotlight/solr_document.rb', line 35

def exhibit_slug_field
  "#{Spotlight::Engine.config.solr_fields.prefix}spotlight_exhibit_slugs#{Spotlight::Engine.config.solr_fields.string_suffix}"
end

#reindex(id) ⇒ Object



25
26
27
28
29
# File 'app/models/concerns/spotlight/solr_document.rb', line 25

def reindex(id)
  find(id).reindex
rescue Blacklight::Exceptions::RecordNotFound => e
  Rails.logger.debug { "Unable to find document #{id}: #{e}" }
end

#reindex_allObject



31
32
33
# File 'app/models/concerns/spotlight/solr_document.rb', line 31

def reindex_all
  find_each(&:reindex)
end

#resource_type_fieldObject



47
48
49
# File 'app/models/concerns/spotlight/solr_document.rb', line 47

def resource_type_field
  :"#{Spotlight::Engine.config.solr_fields.prefix}spotlight_resource_type#{Spotlight::Engine.config.solr_fields.string_suffix}"
end

#solr_field_for_tagger(tagger) ⇒ Object



39
40
41
# File 'app/models/concerns/spotlight/solr_document.rb', line 39

def solr_field_for_tagger(tagger)
  :"#{solr_field_prefix(tagger)}tags#{Spotlight::Engine.config.solr_fields.string_suffix}"
end

#solr_field_prefix(exhibit) ⇒ Object



51
52
53
# File 'app/models/concerns/spotlight/solr_document.rb', line 51

def solr_field_prefix(exhibit)
  "#{Spotlight::Engine.config.solr_fields.prefix}#{exhibit.class.model_name.param_key}_#{exhibit.to_param}_"
end

#visibility_field(exhibit) ⇒ Object



43
44
45
# File 'app/models/concerns/spotlight/solr_document.rb', line 43

def visibility_field(exhibit)
  :"#{solr_field_prefix(exhibit)}public#{Spotlight::Engine.config.solr_fields.boolean_suffix}"
end