Hi Pete,
This is a pretty good solution. We've been updating the lucene index in
the new folder, but copying the final results back to the original
folder when we're done. We have some technical challenges in our
application that we need to resolve before this works, but I think this
is the best answer so far.
Peter Miller wrote:
Hi,
Best practice in a web environment is to generate an incremental update to your
index in a new folder, and on subsequent requests to your web app start
searching/reading from the new index location.
Hope that helps get you started,
Pete
-----Original Message-----
From: Jeff Pennal [mailto:[email protected]]
Sent: 07 August 2009 23:17
To: [email protected]
Subject: Thread safe lucene index writing
We are currently using Lucene.Net 2.3.1 to power the search engine of
our web application. Our architecture works like this:
- The web application queries the index for searches using the
IndexReader/IndexSearcher.
- Whenever content is updated by a user of the web app, the database is
updated and a message is put into a queue indicating that the
content
needs to be updated in the lucene index
- A windows service is running, listening to the queue and when a
message comes in, will update the lucene index using an IndexWriter.
The main objective for us here is to keep the database and the index in
sync. We need to be able to trust that when content is updated and
saved
to the database, the document in the index that represents that content
will be updated asap.
We have run into issues in the past where the IndexWriter cannot update
the index because there is a lock on the file. The usual cause of this
is that the IndexReader has the index open when the writer tries to
write to the index.
Our current workaround for this is when we do updates to the index, we
do the updates in a temporary folder so we wont have to worry about
locks during the updating process. Once the update is done, we replace
the existing index with the newly updated one.
While this does work now, it is not the most robust solution and will
cause us trouble scaling the web app since we want to be able to use
the
lucene index in other areas than search.
Does anyone run Lucene.Net in a similar setup? Have you any ideas on
how
this configuration can be made to be more reliable when it comes to
writing to the index?
Thanks in advance,
Jeff
** Please consider the environment before printing this e-mail **
The information contained in this e-mail is of a confidential nature and is
intended only for the addressee. If you are not the intended addressee, any
disclosure, copying or distribution by you is prohibited and may be unlawful.
Disclosure to any party other than the addressee, whether inadvertent or
otherwise, is not intended to waive privilege or confidentiality. Internet
communications are not secure and therefore Conde Nast does not accept legal
responsibility for the contents of this message. Any views or opinions
expressed are those of the author.
Company Registration details:
The Conde Nast Publications Ltd
Vogue House
Hanover Square
London W1S 1JU
Registered in London No. 226900
--
Jeff Pennal [email protected]
OpenRoad Communications phone: 604.694.0554 x113
Internet Business Solutions fax: 604.694.0558
Vancouver, B.C. http://www.openroad.ca