def batch_update(docs)
      @dir.synchronize do
        ids = nil
        case docs
        when Array
          ids = docs.collect{|doc| doc[@id_field].to_s}
          if ids.include?(nil)
            raise ArgumentError, "all documents must have an #{@id_field} " 
                                 "field when doing a batch update"
          end
        when Hash
          ids = docs.keys
          docs = docs.values
        else
          raise ArgumentError, "must pass Hash or Array, not #{docs.class}"
        end
        batch_delete(ids)
        ensure_writer_open()
        docs.each {|new_doc| @writer << new_doc }
        flush()
      end
    end
def batch_update(docs)
      @dir.synchronize do
        ids = nil
        case docs
        when Array
          ids = docs.collect{|doc| doc[@id_field].to_s}
          if ids.include?(nil)
            raise ArgumentError, "all documents must have an #{@id_field} " 
                                 "field when doing a batch update"
          end
        when Hash
          ids = docs.keys
          docs = docs.values
        else
          raise ArgumentError, "must pass Hash or Array, not #{docs.class}"
        end
        batch_delete(ids)
        ensure_writer_open()
        docs.each {|new_doc| @writer << new_doc }
        flush()
      end
    end
Batch updates the documents in an index. You can pass either a Hash or
 an Array.

 === Array (recommended)

 If you pass an Array then each value needs to be a Document or a Hash
 and each of those documents must have an +:id_field+ which will be used
 to delete the old document that this document is replacing.

 === Hash

 If you pass a Hash then the keys of the Hash will be considered the
 +id+'s and the values will be the new documents to replace the old ones
 with.If the +id+ is an Integer then it is considered a Ferret document
 number and the corresponding document will be deleted.  If the +id+ is a
 String or a Symbol then the +id+ will be considered a term and the
 documents that contain that term in the +:id_field+ will be deleted.

 Note: No error will be raised if the document does not currently
 exist. A new document will simply be created.

 == Examples

   # will replace the documents with the +id+'s id:133 and id:254
   @index.batch_update({
       '133' => {:id => '133', :content => 'yada yada yada'},
       '253' => {:id => '253', :content => 'bla bla bal'}
     })

   # will replace the documents with the Ferret Document numbers 2 and 92
   @index.batch_update({
       2  => {:id => '133', :content => 'yada yada yada'},
       92 => {:id => '253', :content => 'bla bla bal'}
     })

   # will replace the documents with the +id+'s id:133 and id:254
   # this is recommended as it guarantees no duplicate keys
   @index.batch_update([
       {:id => '133', :content => 'yada yada yada'},
       {:id => '253', :content => 'bla bla bal'}
     ])

 docs:: A Hash of id/document pairs. The set of documents to be updated