lib/solrizer/fedora/solrizer.rb in solrizer-fedora-1.1.3 vs lib/solrizer/fedora/solrizer.rb in solrizer-fedora-1.2.0

- old
+ new

@@ -3,19 +3,25 @@ require 'solrizer/fedora/indexer' require 'solrizer/xml' require 'solrizer/html' +require 'active_support/core_ext/hash' # Let people explicitly require xml support if they want it ... # require 'solrizer/xml.rb' require 'fastercsv' # this is used by solrize_objects when you pass it a csv file of pids require "ruby-debug" module Solrizer::Fedora class Solrizer + ALL_FIELDS = [ + :pid, :label, :fType, :cModel, :state, :ownerId, :cDate, :mDate, :dcmDate, + :bMech, :title, :creator, :subject, :description, :contributor, + :date, :type, :format, :identifier, :source, :language, :relation, :coverage, :rights + ] attr_accessor :indexer, :index_full_text # # This method initializes the indexer @@ -91,11 +97,11 @@ num_docs = 1000000 # modify this number to guarantee that all the objects are retrieved from the repository puts "WARNING: You have turned off indexing of Full Text content. Be sure to re-run indexer with @@index_full_text set to true in main.rb" if index_full_text == false if @@index_list == false - objects = ::Fedora::Repository.instance.find_objects(:limit=>num_docs) + objects = find_objects(:limit=>num_docs) puts "Shelving #{objects.length} Fedora objects" objects.each do |object| solrize( object, opts ) end @@ -116,8 +122,22 @@ puts "#{@@index_list} does not exists!" end #if File.exists end #if Index_LISTS end #solrize_objects + + def find_objects(*args) + raise ArgumentError, "Missing query string" unless args.length >= 1 + options = args.last.is_a?(Hash) ? args.pop : {} + + params = {} + params[:query] = '' + params[:maxResults] = options[:limit] if options[:limit] + params[:pid] = true + connection = ActiveFedora::RubydoraConnection.instance.connection + response = Hash.from_xml(connection.find_objects(params)) + response["result"]["resultList"]["objectFields"].map{|x| x["pid"]} + end + end #class end #module