Hi, I seem to be having trouble updating a doc, ie, deleting then re-adding to the index. The following script demonstrates my issue - I''m sure I''m missing something obvious, but I can''t seem to find the problem. Can someone point out where I am going wrong please ? Regards Neville ==require ''rubygems'' require ''ferret'' p Ferret::VERSION @dir = Ferret::Store::RAMDirectory.new @index = Ferret::Index::Index.new(:dir => @dir) (1..1000).each do |n| @index << {:id => "doc#{n}", :name => "name #{n}"} end @doc_999 = @index["doc999"] @doc_999.load if @doc_999 p "doc_999 not found" unless @doc_999 p "doc_999 name=#{@doc_999[:name]}" if @doc_999 @new_doc = {:id => "doc999", :name => "fred"} p "deleting and adding new doc999" @index.delete("doc999") @index << @new_doc @doc_999 = @index["doc999"] @doc_999.load if @doc_999 p "new_doc_999 not found" unless @doc_999 p "new_doc_999 name=#{@doc_999[:name]}" if @doc_999 @index.close @index = nil == $> ruby test_delete2.rb "0.10.4" "doc_999 name=name 999" "deleting and adding new doc999" "new_doc_999 not found"
BTW, I just ran the same script [ie, without #load] with Ferret 0.9.3 and it worked "correctly", ie, "fred" is found as I expect. -----Original Message----- From: ferret-talk-bounces at rubyforge.org [mailto:ferret-talk-bounces at rubyforge.org] On Behalf Of Neville Burnell Sent: Friday, 15 September 2006 3:08 PM To: ferret-talk at rubyforge.org Subject: [Ferret-talk] Trouble with "updating" a document Hi, I seem to be having trouble updating a doc, ie, deleting then re-adding to the index. The following script demonstrates my issue - I''m sure I''m missing something obvious, but I can''t seem to find the problem. Can someone point out where I am going wrong please ? Regards Neville ==require ''rubygems'' require ''ferret'' p Ferret::VERSION @dir = Ferret::Store::RAMDirectory.new @index = Ferret::Index::Index.new(:dir => @dir) (1..1000).each do |n| @index << {:id => "doc#{n}", :name => "name #{n}"} end @doc_999 = @index["doc999"] @doc_999.load if @doc_999 p "doc_999 not found" unless @doc_999 p "doc_999 name=#{@doc_999[:name]}" if @doc_999 @new_doc = {:id => "doc999", :name => "fred"} p "deleting and adding new doc999" @index.delete("doc999") @index << @new_doc @doc_999 = @index["doc999"] @doc_999.load if @doc_999 p "new_doc_999 not found" unless @doc_999 p "new_doc_999 name=#{@doc_999[:name]}" if @doc_999 @index.close @index = nil == $> ruby test_delete2.rb "0.10.4" "doc_999 name=name 999" "deleting and adding new doc999" "new_doc_999 not found" _______________________________________________ Ferret-talk mailing list Ferret-talk at rubyforge.org http://rubyforge.org/mailman/listinfo/ferret-talk
On 9/15/06, Neville Burnell <Neville.Burnell at bmsoft.com.au> wrote:> BTW, I just ran the same script [ie, without #load] with Ferret 0.9.3 > and it worked "correctly", ie, "fred" is found as I expect. > > -----Original Message----- > From: ferret-talk-bounces at rubyforge.org > [mailto:ferret-talk-bounces at rubyforge.org] On Behalf Of Neville Burnell > Sent: Friday, 15 September 2006 3:08 PM > To: ferret-talk at rubyforge.org > Subject: [Ferret-talk] Trouble with "updating" a document > > Hi, > > I seem to be having trouble updating a doc, ie, deleting then re-adding > to the index. > > The following script demonstrates my issue - I''m sure I''m missing > something obvious, but I can''t seem to find the problem. Can someone > point out where I am going wrong please ? > > Regards > > Neville > > ==> require ''rubygems'' > require ''ferret'' > > p Ferret::VERSION > > @dir = Ferret::Store::RAMDirectory.new > > @index = Ferret::Index::Index.new(:dir => @dir) > > (1..1000).each do |n| > @index << {:id => "doc#{n}", :name => "name #{n}"} > end > > @doc_999 = @index["doc999"] > @doc_999.load if @doc_999 > p "doc_999 not found" unless @doc_999 > p "doc_999 name=#{@doc_999[:name]}" if @doc_999 > > @new_doc = {:id => "doc999", :name => "fred"} > > p "deleting and adding new doc999" > @index.delete("doc999") > @index << @new_doc > > @doc_999 = @index["doc999"] > @doc_999.load if @doc_999 > p "new_doc_999 not found" unless @doc_999 > p "new_doc_999 name=#{@doc_999[:name]}" if @doc_999 > > @index.close > @index = nil > > ==> > $> ruby test_delete2.rb > "0.10.4" > "doc_999 name=name 999" > "deleting and adding new doc999" > "new_doc_999 not found"Hi Neville, Thanks for letting me know about this. It has been fixed in the current version. I''ll get a new gem out soon. Cheers, Dave