I’m playing with “updating” docs in my index, and I think I’ve found bug
with IndexWriter counting deleted docs. Script and output follow:
=====
require ‘rubygems’
require ‘ferret’
p Ferret::VERSION
@doc = {:id => ‘44’, :name => ‘fred’, :email => ‘[email protected]’}
@dir = Ferret::Store::RAMDirectory.new
def add_then_delete_fred
@writer = Ferret::Index::IndexWriter.new(:dir => @dir)
p “adding doc :id=#{@doc[:id]}”
@writer << @doc
p “doc_count=#{@writer.doc_count}”
p “deleting doc :id=#{@doc[:id]}”
@writer.delete(:id, @doc[:id])
p “doc_count=#{@writer.doc_count}”
@writer.commit
@writer.close
@writer = nil
end
add_then_delete_fred
add_then_delete_fred
add_then_delete_fred
@reader = Ferret::Index::IndexReader.new(@dir)
p “reader count=#{@reader.num_docs}”
@writer = Ferret::Index::IndexWriter.new(:dir => @dir)
p “writer count=#{@writer.doc_count}”
===
$>ruby test_delete.rb
“0.10.4”
“adding doc :id=44”
“doc_count=1”
“deleting doc :id=44”
“doc_count=1”
“adding doc :id=44”
“doc_count=2”
“deleting doc :id=44”
“doc_count=2”
“adding doc :id=44”
“doc_count=3”
“deleting doc :id=44”
“doc_count=3”
“reader count=0”
“writer count=3”