Class: Spotlight::Search
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::Search
- Extended by:
- FriendlyId
- Includes:
- Blacklight::SolrHelper, Catalog::AccessControlsEnforcement
- Defined in:
- app/models/spotlight/search.rb
Instance Method Summary collapse
- #count ⇒ Object
- #default_featured_item_id ⇒ Object
- #featured_image ⇒ Object
- #featured_item ⇒ Object
- #images ⇒ Object
Instance Method Details
#count ⇒ Object
32 33 34 |
# File 'app/models/spotlight/search.rb', line 32 def count query_solr(query_params, rows: 0, facet: false)['response']['numFound'] end |
#default_featured_item_id ⇒ Object
53 54 55 |
# File 'app/models/spotlight/search.rb', line 53 def default_featured_item_id images.first.first if images.present? end |
#featured_image ⇒ Object
26 27 28 29 30 |
# File 'app/models/spotlight/search.rb', line 26 def featured_image if featured_item Array[featured_item[blacklight_config.index.thumbnail_field]].flatten.first end end |
#featured_item ⇒ Object
20 21 22 23 24 |
# File 'app/models/spotlight/search.rb', line 20 def featured_item if self.featured_item_id.present? @featured_item ||= get_solr_response_for_doc_id(self.featured_item_id).last end end |
#images ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/models/spotlight/search.rb', line 36 def images response = query_solr(query_params, rows: 1000, fl: [blacklight_config.solr_document_model.unique_key, blacklight_config.index.title_field, blacklight_config.index.thumbnail_field], facet: false) Blacklight::SolrResponse.new(response, {}).docs.map do |result| doc = ::SolrDocument.new(result) [ doc.first(blacklight_config.solr_document_model.unique_key), doc.first(blacklight_config.index.title_field), doc.first(blacklight_config.index.thumbnail_field) ] end end |