Class: Spotlight::Search
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::Search
- Extended by:
- FriendlyId
- Includes:
- Blacklight::SearchHelper, Catalog::AccessControlsEnforcement
- Defined in:
- app/models/spotlight/search.rb
Instance Method Summary collapse
- #blacklight_config ⇒ Object
- #count ⇒ Object
- #display_masthead? ⇒ Boolean
- #documents ⇒ Object
- #images ⇒ Object
- #thumbnail_image_url ⇒ Object
Instance Method Details
#blacklight_config ⇒ Object
52 53 54 |
# File 'app/models/spotlight/search.rb', line 52 def blacklight_config exhibit.blacklight_config end |
#count ⇒ Object
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
56 57 58 |
# File 'app/models/spotlight/search.rb', line 56 def display_masthead? masthead && masthead.display? end |
#documents ⇒ Object
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 |
#images ⇒ Object
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_url ⇒ Object
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 |