Sha256: e2e06b0309376ef7fc960b7376184f056899090ddf2a12f4be936f0383a5568c
Contents?: true
Size: 1.49 KB
Versions: 26
Compression:
Stored size: 1.49 KB
Contents
# frozen_string_literal: true module Valkyrie::Persistence::Solr::Queries # Responsible for efficiently returning all objects in the solr repository as # {Valkyrie::Resource}s class FindAllQuery attr_reader :connection, :resource_factory, :model # @param [RSolr::Client] connection # @param [ResourceFactory] resource_factory # @param [Class] model def initialize(connection:, resource_factory:, model: nil) @connection = connection @resource_factory = resource_factory @model = model end # Iterate over each Solr Document and convert each Document into a Valkyrie Resource # @return [Array<Valkyrie::Resource>] def run enum_for(:each) end # Queries for all Documents in the Solr index # For each Document, it yields the Valkyrie Resource which was converted from it # @yield [Valkyrie::Resource] def each docs = DefaultPaginator.new while docs.has_next? docs = connection.paginate(docs.next_page, docs.per_page, "select", params: { q: query })["response"]["docs"] docs.each do |doc| yield resource_factory.to_resource(object: doc) end end end # Generates the Solr query for retrieving all Documents in the index # If a model is specified for the query, it is scoped to that Valkyrie resource type # @return [String] def query if !model "*:*" else "#{Valkyrie::Persistence::Solr::Queries::MODEL}:#{model}" end end end end
Version data entries
26 entries across 26 versions & 1 rubygems