Many Searchers & one Indexer can work concurrently. What I want to try to
say is you can not open two IndexWriter for the same Index.

DIGY.

-----Original Message-----
From: Corey Trager [mailto:[EMAIL PROTECTED] 
Sent: Sunday, October 12, 2008 5:00 AM
To: lucene-net-user@incubator.apache.org
Subject: RE: Multiple threads updating/reading the same index in an ASP.NET
website. - IndexModifier

Digg - thanks. I originally wrote this at StackOverflow.com.  Do you think I
understand things
now, based on what I wrote here:


"....After reading docs and experimentation, this is what I think I've
learned: There are two
issues, thread safety and concurrency. Multithreading is "safe" in that you
can't do anything bad
to the index. But, it's safe at the cost of just one object having a lock on
the index at one
time. The second object will come along and throw an exception. So, you
can't leave a search open
and expect a writer in another thread to be able to update the index. And if
a thread is busy
updating the index, then trying to create a searcher will fail.

Also, Searchers see the index as it was at the time that they open it, so if
you keep them around,
and update the index, they won't see the updates.

I wanted my searchers to see the latest updates.

My design, and it seems to be working so far, is that my writers and
searchers share a lock, so
that they don't fail - they just wait - until the current write or search is
done...."


--- Digy <[EMAIL PROTECTED]> wrote:

> Sorry, I forgot to say that I was talking about Lucene.Net 2.3.1
> In Version 2.3.1, IndexWriter class has UpdateDocuments and
DeleteDocuments
> methods. So you don't have to use
> IndexModifier to add or delete documents.
> 
> (IndexModifier is a wrapper for IndexWriter+IndexReader. If you call
> AddDocument it closes IndexReader(if open), opens the IndexWriter and
calls
> its AddDocument method. If you want to delete a document it closes the
> IndexWriter(if open), opens the IndexReader and then calls its
> DeleteDocuments method. So it is not an efficient implementation.
Therefore
> I don't think that having one instance of IndexModifier will change things
> much)
> 
> >In the sample code, and my code, I see that there's a call to "Close" on
> IndexSearcher.   Should I
> >omit that call, and leave it always open?
> 
> Again for 2.3.1, IndexSearcher will not "see" the updates made by
> IndexWriter unless you reopen it.
> 
> DIGY
> 
> 
> -----Original Message-----
> From: Corey Trager [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, October 12, 2008 12:52 AM
> To: lucene-net-user@incubator.apache.org
> Subject: RE: Multiple threads updating/reading the same index in an
ASP.NET
> website. - IndexModifier
> 
> And, the same with IndexModifier, right?  I should have one single
instance
> of it and all threads
> use that same instance?
> 
> --- Digy <[EMAIL PROTECTED]> wrote:
> 
> > Yes Lucene has build-in concurrency management. You can freely search
and
> > update the same index in different threads. One point here is that you
> have
> > to use the same instance of the IndexWriter in updating threads. Trying
to
> > open the same index twice will throw exception. It is also recommended
to
> > share a single IndexSearcher across threads for better performance.
> > 
> > DIGY
> > 
> > -----Original Message-----
> > From: Corey Trager [mailto:[EMAIL PROTECTED] 
> > Sent: Saturday, October 11, 2008 7:36 PM
> > To: lucene-net-user@incubator.apache.org
> > Subject: Multiple threads updating/reading the same index in an ASP.NET
> > website.
> > 
> > Does Lucene.Net have built into it logic for managing concurrency,
> multiple
> > threads?   If a
> > request comes to my website that triggers a thread to update the index,
> and
> > another request comes
> > on another thread that also triggers a request to update, or even read,
> the
> > index, does Lucene
> > handle the management of concurrency, or do I need to?
> > 
> > 
> >       
> > 
> > 
> 
> 
> 
>       
> 
> 



      

Reply via email to