Hi all,

I would like to share with you the integration process of this
searching code (Whoosh) in my web2py application. For those who don't
know it, Whoosh is a search engine fully written in python, so it is
easy to use in a framework such as web2py, but with some little
issues. Well, after placing the source code of Whoosh in modules
section, and writing the proper imports, we are ready to go using it.

The problem comes when, reading whoosh documentation, we find out that
when indexing a document, whoosh lock the index (it is just locked to
write, you can read in while indexing). So, how to solve this
imposibility of concurrency? (Imagine that two users are performing
actions which require an indexation at the same time... one of them
would return an error).

What I did is to create a queue, and a cron script that looks into
that queue and process it. The queue is a simple table in the
database, with all the fields to be indexed, that stores a record
everytime a user performs an action that needs to index something.

Then, the cron script reads that table, locks the index, indexes the
records in the queue, and frees the index.

I hope this help someone... if you have any doubts, please do not
hesitate in asking.

regards,
Bernardo

Reply via email to