provide the Solr connection to clients of the indexer

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@539800 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2007-05-19 20:48:26 +00:00
parent ec60053d44
commit 20c42cc6f2
1 changed files with 4 additions and 6 deletions

View File

@ -11,12 +11,9 @@
# limitations under the License.
class Solr::Indexer
# deprecated, use Indexer.new(ds,mapping).index instead
def self.index(data_source, mapper_or_mapping, options={})
indexer = Solr::Indexer.new(data_source, mapper_or_mapping, options)
indexer.index
end
attr_reader :solr
# TODO: document options!
def initialize(data_source, mapper_or_mapping, options={})
solr_url = options[:solr_url] || ENV["SOLR_URL"] || "http://localhost:8983/solr"
@solr = Solr::Connection.new(solr_url, options) #TODO - these options contain the solr_url and debug keys also, so tidy up what gets passed
@ -33,7 +30,8 @@ class Solr::Indexer
@data_source.each do |record|
document = @mapper.map(record)
yield(record, document) if block_given? # TODO check return of block, if not true then don't index
# TODO: check arrity of block, if 3, pass counter as 3rd argument
yield(record, document) if block_given? # TODO check return of block, if not true then don't index, or perhaps if document.empty?
buffer << document