Class: Spotlight::Search

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Includes:
Blacklight::SearchHelper, Catalog::AccessControlsEnforcement
Defined in:
app/models/spotlight/search.rb

Instance Method Summary collapse

Instance Method Details

#blacklight_configObject



52
53
54
# File 'app/models/spotlight/search.rb', line 52

def blacklight_config
  exhibit.blacklight_config
end

#countObject



29
30
31
# File 'app/models/spotlight/search.rb', line 29

def count
  query_solr(query_params, rows: 0, facet: false)['response']['numFound']
end

#display_masthead?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/models/spotlight/search.rb', line 56

def display_masthead?
  masthead && masthead.display?
end

#documentsObject



44
45
46
47
48
49
50
# File 'app/models/spotlight/search.rb', line 44

def documents
  return enum_for(:documents) unless block_given?

  Blacklight::SolrResponse.new(solr_response, {}).docs.each do |result|
    yield blacklight_config.document_model.new(result)
  end
end

#imagesObject



33
34
35
36
37
38
39
40
41
42
# File 'app/models/spotlight/search.rb', line 33

def images
  documents.map do |doc|

    [
      doc.first(blacklight_config.document_model.unique_key),
      doc.first(blacklight_config.index.title_field),
      doc.first(blacklight_config.index.thumbnail_field)
    ]
  end
end

#thumbnail_image_urlObject



25
26
27
# File 'app/models/spotlight/search.rb', line 25

def thumbnail_image_url
  thumbnail.image.thumb.url if thumbnail and thumbnail.image
end