Forum: Ferret Offline indexing with Drb, online using index in Rails?

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.
3a6666f57152610f172a77c8fe6a7420?d=identicon&s=25 Marcus Andersson (marcan)
on 2006-05-24 09:57
I have a Rails application where I need to search. Every time an update
happens to something I need to update the index for the changed and
related document. As I currently have to run on Windows (and therefore
can't use the native extension) it is quite slow to index sometimes and
the user have to wait a couple of seconds for the save operation to
return.

A thought is to put this outside the Rails application in an external
service that is called through Drb. Is it possible to index with one
application and use the index with another at the same time?

Regards,

Marcus
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2006-05-24 10:01
(Received via mailing list)
On Wed, May 24, 2006 at 09:57:13AM +0200, Marcus Andersson wrote:
> I have a Rails application where I need to search. Every time an update
> happens to something I need to update the index for the changed and
> related document. As I currently have to run on Windows (and therefore
> can't use the native extension) it is quite slow to index sometimes and
> the user have to wait a couple of seconds for the save operation to
> return.
>
> A thought is to put this outside the Rails application in an external
> service that is called through Drb. Is it possible to index with one
> application and use the index with another at the same time?

as long as only one process is writing to the index that's fine. But you
have to reopen searchers to see the changes done to the index.

Jens


--
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       kraemer@webit.de
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
3a6666f57152610f172a77c8fe6a7420?d=identicon&s=25 Marcus Andersson (marcan)
on 2006-05-24 14:35
Jens Kraemer wrote:
> On Wed, May 24, 2006 at 09:57:13AM +0200, Marcus Andersson wrote:
> as long as only one process is writing to the index that's fine. But you
> have to reopen searchers to see the changes done to the index.
>
How does that work in a normal Rails application if you run in a
production environment (ie cluster of Mongrels, FCGI or SCGI where you
always have a number of processes running)? I mean, every instance of
the Rails env might want to add something to or read from the index.

/Marcus
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2006-05-24 15:58
(Received via mailing list)
On Wed, May 24, 2006 at 02:35:20PM +0200, Marcus Andersson wrote:
> Jens Kraemer wrote:
> > On Wed, May 24, 2006 at 09:57:13AM +0200, Marcus Andersson wrote:
> > as long as only one process is writing to the index that's fine. But you
> > have to reopen searchers to see the changes done to the index.
> >
> How does that work in a normal Rails application if you run in a
> production environment (ie cluster of Mongrels, FCGI or SCGI where you
> always have a number of processes running)? I mean, every instance of
> the Rails env might want to add something to or read from the index.

there's a file based locking mechanism, Ferret's index class handles
possible collisions by waiting and retrying the write after a short
time.
It also handles re-opening the searcher for you.

If you don't use the Index class it's up to you to detect changes to the
index and re-open your searcher. there's a method named latest?
somewhere, you could look into the Index class to see how it's done
there.

Jens


--
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       kraemer@webit.de
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
This topic is locked and can not be replied to.