Forum: Ferret Rebuild Indexes Issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
22580f640e491f0920a192610d1df393?d=identicon&s=25 Tom Davies (Guest)
on 2006-05-30 13:51
(Received via mailing list)
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 Davies

http://blog.atomgiant.com
http://gifthat.com
B5e329ffa0cc78efbfc7ae2d084c149f?d=identicon&s=25 David Balmain (Guest)
on 2006-05-30 14:44
(Received via mailing list)
On 5/30/06, Tom Davies <atomgiant@gmail.com> 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
22580f640e491f0920a192610d1df393?d=identicon&s=25 Tom Davies (Guest)
on 2006-05-30 15:15
(Received via mailing list)
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 Balmain <dbalmain.ml@gmail.com> wrote:
> >     INDEX.size.times {|i| INDEX.delete(i)}
> > 0.9 on windows.
> Dave
> _______________________________________________
> Ferret-talk mailing list
> Ferret-talk@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ferret-talk
>


--
Tom Davies

http://blog.atomgiant.com
http://gifthat.com
B5e329ffa0cc78efbfc7ae2d084c149f?d=identicon&s=25 David Balmain (Guest)
on 2006-05-30 15:18
(Received via mailing list)
On 5/30/06, Tom Davies <atomgiant@gmail.com> 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
This topic is locked and can not be replied to.