Module: Spotlight::SolrDocument::Finder::ClassMethods

Defined in:
app/models/concerns/spotlight/solr_document/finder.rb

Overview

Class level finder methods for documents

Instance Method Summary collapse

Instance Method Details

#find(id) ⇒ Object



13
14
15
16
# File 'app/models/concerns/spotlight/solr_document/finder.rb', line 13

def find(id)
  solr_response = index.find(id)
  solr_response.documents.first
end

#find_eachObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/concerns/spotlight/solr_document/finder.rb', line 22

def find_each
  return to_enum(:find_each) unless block_given?

  start = 0
  search_params = { q: '*:*', fl: 'id', facet: false }
  response = index.search(search_params.merge(start: start))

  while response.documents.present?
    response.documents.each { |x| yield x }
    start += response.documents.length
    response = index.search(search_params.merge(start: start))
  end
end

#indexObject



18
19
20
# File 'app/models/concerns/spotlight/solr_document/finder.rb', line 18

def index
  @index ||= blacklight_config.repository_class.new(blacklight_config)
end