On Jan 29, 2007, at 7:08 PM, Yonik Seeley wrote:

On 1/29/07, Antonio Eggberg <[EMAIL PROTECTED]> wrote:
Is it a good practice to do <commit> after every insert .. is this what is taking the time.. are there any general rule of thumb.

Definitely don't do a commit after every insert. Do a single one at the end.

For sure. solrb has an autocommit flag that was initially contributed as on by default, but I turned it off by default before committing. autocommit is handy for little demos (see solrb README, pasted below) and one-off communication, but not at all suitable for batch runs.

        Erik

  require 'solr'  # load the library
include Solr # Allow Solr:: to be omitted from class/module references

  # connect to the solr instance
conn = Connection.new('http://localhost:8983/solr', :autocommit => :on)

  # add a document to the index
  conn.add(:id => 123, :title_text => 'Lucene in Action')

  # update the document
  conn.update(:id => 123, :title_text => 'Solr in Action')

  # print out the first hit in a query for 'action'
  response = conn.query('action')
  print response.hits[0]

  # iterate through all the hits for 'action'
  conn.query('action') do |hit|
    puts hit.inspect
  end

  # delete document by id
  conn.delete(123)

Reply via email to