Class: Spotlight::Search
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::Search
- Extended by:
- FriendlyId
- Includes:
- Translatables
- Defined in:
- app/models/spotlight/search.rb
Overview
Exhibit saved searches
Instance Method Summary collapse
- #count ⇒ Object
- #display_masthead? ⇒ Boolean
- #documents ⇒ Object
- #merge_params_for_search(params, blacklight_config) ⇒ Object
- #search_params ⇒ Object
- #thumbnail_image_url ⇒ Object
Instance Method Details
#count ⇒ Object
44 45 46 |
# File 'app/models/spotlight/search.rb', line 44 def count documents.size end |
#display_masthead? ⇒ Boolean
50 51 52 |
# File 'app/models/spotlight/search.rb', line 50 def display_masthead? masthead && masthead.display? end |
#documents ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/spotlight/search.rb', line 31 def documents start = 0 response = repository.search(search_params.start(start)) return to_enum(:documents) { response['response']['numFound'] } unless block_given? while response.documents.present? response.documents.each { |x| yield x } start += response.documents.length response = repository.search(search_params.start(start)) end end |
#merge_params_for_search(params, blacklight_config) ⇒ Object
58 59 60 61 62 |
# File 'app/models/spotlight/search.rb', line 58 def merge_params_for_search(params, blacklight_config) base_query = Blacklight::SearchState.new(query_params, blacklight_config) user_query = Blacklight::SearchState.new(params, blacklight_config).to_h base_query.params_for_search(user_query).merge(user_query.slice(:page)) end |
#search_params ⇒ Object
54 55 56 |
# File 'app/models/spotlight/search.rb', line 54 def search_params search_builder.with(query_params.with_indifferent_access).merge(facet: false, fl: default_search_fields) end |
#thumbnail_image_url ⇒ Object
25 26 27 28 29 |
# File 'app/models/spotlight/search.rb', line 25 def thumbnail_image_url return unless thumbnail && thumbnail.iiif_url thumbnail.iiif_url end |