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
11 12 13 14 |
# File 'app/models/concerns/spotlight/solr_document/finder.rb', line 11 def find(id) solr_response = index.find(id) solr_response.documents.first end |
#find_each ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/concerns/spotlight/solr_document/finder.rb', line 20 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 |
#index ⇒ Object
16 17 18 |
# File 'app/models/concerns/spotlight/solr_document/finder.rb', line 16 def index @index ||= blacklight_config.repository_class.new(blacklight_config) end |