Class: Spotlight::Search

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Includes:
Translatables
Defined in:
app/models/spotlight/search.rb

Overview

Exhibit saved searches

Instance Method Summary collapse

Instance Method Details

#countObject



46
47
48
# File 'app/models/spotlight/search.rb', line 46

def count
  documents.size
end

#display_masthead?Boolean

Returns:

  • (Boolean)


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

def display_masthead?
  masthead && masthead.display?
end

#documentsObject



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

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



60
61
62
63
64
# File 'app/models/spotlight/search.rb', line 60

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_paramsObject



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

def search_params
  search_builder.with(query_params.with_indifferent_access).merge(facet: false, fl: default_search_fields)
end

#thumbnail_image_urlObject



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

def thumbnail_image_url
  return unless thumbnail && thumbnail.iiif_url

  thumbnail.iiif_url
end