Offline indexing with Drb, online using index in Rails?


#1

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


#2

On Wed, May 24, 2006 at 09:57:13AM +0200, Marcus A. 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 removed_email_address@domain.invalid
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66


#3

Jens K. wrote:

On Wed, May 24, 2006 at 09:57:13AM +0200, Marcus A. 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


#4

On Wed, May 24, 2006 at 02:35:20PM +0200, Marcus A. wrote:

Jens K. wrote:

On Wed, May 24, 2006 at 09:57:13AM +0200, Marcus A. 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 removed_email_address@domain.invalid
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66