Rebuild Indexes Issue

Hi,

I have some code to rebuild my ferret indexes but occasionally some
stale documents remain in the index even after rebuilding. The only
way I could find around this is to manually delete the index files
from the filesystem. Here is the code I have for rebuilding one of my
indexes for Gifts:

# delete existing entries
INDEX.size.times {|i| INDEX.delete(i)}

gifts = Gift.find(:all)
if (gifts)
  gifts.each do |e|
    INDEX << self.to_doc
  end
end
INDEX.flush()

Does this look ok? I have verified this behavior on Ferret 0.3.2 and
0.9 on windows.

Thanks,
Tom D.

http://blog.atomgiant.com
http://gifthat.com

On 5/30/06, Tom D. [email protected] wrote:

gifts = Gift.find(:all)
if (gifts)
  gifts.each do |e|
    INDEX << self.to_doc
  end
end
INDEX.flush()

Does this look ok? I have verified this behavior on Ferret 0.3.2 and
0.9 on windows.

Hi Tom,

This looks fine. Personally, I would just reopen the index with
:create => true rather than deleting all the documents but it should
still work. I have no idea why stale documents would be remaining in
the index. Do you have more than one process writing to the index? Can
you narrow this behaviour down to a simple test case?

Cheers,
Dave

Hi Dave,

Only one process is writing to the index in this case. If I can
narrow it down to a specific example I will try to roll it into a test
case. In the mean time I will try the :create => true and perhaps
this may bypass the issue altogether.

The reason I was deleting the documents that way was based on one of
the How Tos on your Trac wiki. I would give you a specific link but
your site seems to be giving 500s at the moment. Perhaps the :create
=> true syntax should also be listed there?

Thanks again.
Tom

On 5/30/06, David B. [email protected] wrote:

INDEX.size.times {|i| INDEX.delete(i)}

0.9 on windows.
Dave


Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk


Tom D.

http://blog.atomgiant.com
http://gifthat.com

On 5/30/06, Tom D. [email protected] wrote:

The reason I was deleting the documents that way was based on one of
the How Tos on your Trac wiki. I would give you a specific link but
your site seems to be giving 500s at the moment. Perhaps the :create
=> true syntax should also be listed there?

I’ve been battling with the server all day. I’ll check the wiki out
when I get it up again.

Cheers,
Dave