Class: Spotlight::Search
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::Search
show all
- Extended by:
- FriendlyId
- Includes:
- SearchHelper, Translatables
- Defined in:
- app/models/spotlight/search.rb
Overview
Instance Method Summary
collapse
#search_service, #search_service_context
Instance Method Details
#base_search_state ⇒ Object
91
92
93
|
# File 'app/models/spotlight/search.rb', line 91
def base_search_state
Blacklight::SearchState.new((query_params || {}).with_indifferent_access, blacklight_config, nil)
end
|
#count ⇒ Object
66
67
68
69
70
|
# File 'app/models/spotlight/search.rb', line 66
def count
@count ||= Rails.cache.fetch([exhibit, self, 'count']) do
documents.size
end
end
|
78
79
80
|
# File 'app/models/spotlight/search.rb', line 78
def display_masthead?
masthead&.display?
end
|
#documents ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/models/spotlight/search.rb', line 53
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(&)
start += response.documents.length
response = repository.search(search_params.start(start))
end
end
|
#full_title ⇒ Object
43
44
45
|
# File 'app/models/spotlight/search.rb', line 43
def full_title
[title, subtitle.presence].compact.join(' · ')
end
|
#merge_params_for_search(params, blacklight_config) ⇒ Object
86
87
88
89
|
# File 'app/models/spotlight/search.rb', line 86
def merge_params_for_search(params, blacklight_config)
user_query = Blacklight::SearchState.new(params, blacklight_config, nil).to_h
base_search_state.params_for_search(user_query).merge(user_query.slice(:page))
end
|
#query_params ⇒ Object
72
73
74
|
# File 'app/models/spotlight/search.rb', line 72
def query_params
super || {}.with_indifferent_access
end
|
#search_params ⇒ Object
82
83
84
|
# File 'app/models/spotlight/search.rb', line 82
def search_params
search_service.search_builder.with(base_search_state).merge(facet: false)
end
|
#thumbnail_image_url ⇒ Object
47
48
49
50
51
|
# File 'app/models/spotlight/search.rb', line 47
def thumbnail_image_url
return unless thumbnail&.iiif_url
thumbnail.iiif_url
end
|