Sha256: 7597bf6466dd350bc9d1cfe4e7ebfb4c02b333980ff6d6c9edaa272895ca60e3

Contents?: true

Size: 862 Bytes

Versions: 4

Compression:

Stored size: 862 Bytes

Contents

module Cul
  module Fedora
    class Solr
      attr_reader :url
      def initialize(config = {})
        @url = config[:url] || raise(ArgumentError, "must provide url")

      end

      def rsolr
        @rsolr ||= RSolr.connect(:url => @url)
      end

      def ingest(options = {})
        format = options.delete(:format) || raise(ArgumentError, "needs format")
        items = options.delete(:items) || []
        items = [items] unless items.kind_of?(Array)
        
        collections = options.delete(:collections) || []
        collections = [collections] unless collections.kind_of?(Array)
        collections.each do |collection|
          items |= collection.listMembers
        end



        rsolr.add(items.collect { |i| i.send("index_for_#{format}")}.reject { |doc| doc == {}})
       
        rsolr.commit
      end

    end
    

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cul-fedora-0.5.1 lib/cul-fedora/solr.rb
cul-fedora-0.5.0 lib/cul-fedora/solr.rb
cul-fedora-0.3.0 lib/cul-fedora/solr.rb
cul-fedora-0.2.2 lib/cul-fedora/solr.rb