You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Corey Trager <ct...@yahoo.com> on 2008/10/11 18:35:52 UTC

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?


      

Re: Multiple threads updating/reading the same index in an ASP.NET website.

Posted by Andrew Rimmer <ge...@googlemail.com>.
It is usually best to cache the IndexSearcher across requests. If you have
to keep re-opening an IndexSearcher for each search you lose out on any
caching that Lucene can do. I usually just put it in the cache for x
minutes.

The IndexWriter works great with multiple threads. I usually have one
IndexWriter open, and then throw as many threads at it as the hardware
allows.

Andrew

Re: Multiple threads updating/reading the same index in an ASP.NET website.

Posted by Michael Neel <mi...@gmail.com>.
If you have access to the server (i.e. not a shared hosting
environment), I've been happy with running Lucene as a Windows Service
and accessing it from ASP.NET (w/WCF).  The service uses the
RAMdirectory to handle queries (Lucene's indexes are pretty small, and
can fit into RAM easily) and updates are handled to an FSDirectory.
After the updates are done, I just reload the RAMDirectory from the
file system's version.

It all depends on your specific setup, but the above has been running
smoothly for months now (intranet of 2000 users).

Mike

On Mon, Oct 13, 2008 at 11:35 AM, Doug Sale <do...@gmail.com> wrote:
> How you handle lifecycle issues depends on your requirements.
>
> The simplest thing to do is to create/destroy your application's IndexWriter
> and IndexSearcher within the lifecycle hooks of the application container.
>
> You may also choose to pool IndexWriter and IndexSearcher (even though there
> is likely only one IndexWriter and possibly only one IndexSearcher).  You
> can utilize the hooks of the pooling mechanism to ensure the health of your
> IndexWriter and IndexSearcher(s) instances.
>
> -Doug
>
> On Sat, Oct 11, 2008 at 4:47 PM, Corey Trager <ct...@yahoo.com> wrote:
>
>> 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?
>>
>>
>> --- Digy <di...@gmail.com> 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:ctrager@yahoo.com]
>> > 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?
>> >
>> >
>> >
>> >
>> >
>>
>>
>>
>>
>>
>

Re: Multiple threads updating/reading the same index in an ASP.NET website.

Posted by Doug Sale <do...@gmail.com>.
How you handle lifecycle issues depends on your requirements.

The simplest thing to do is to create/destroy your application's IndexWriter
and IndexSearcher within the lifecycle hooks of the application container.

You may also choose to pool IndexWriter and IndexSearcher (even though there
is likely only one IndexWriter and possibly only one IndexSearcher).  You
can utilize the hooks of the pooling mechanism to ensure the health of your
IndexWriter and IndexSearcher(s) instances.

-Doug

On Sat, Oct 11, 2008 at 4:47 PM, Corey Trager <ct...@yahoo.com> wrote:

> 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?
>
>
> --- Digy <di...@gmail.com> 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:ctrager@yahoo.com]
> > 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?
> >
> >
> >
> >
> >
>
>
>
>
>

RE: Multiple threads updating/reading the same index in an ASP.NET website. - IndexModifier

Posted by Digy <di...@gmail.com>.
I am also not sure but that functionality may have come with Lucene 2.3

DIGY

-----Original Message-----
From: Corey Trager [mailto:ctrager@yahoo.com] 
Sent: Sunday, October 12, 2008 4:26 PM
To: lucene-net-user@incubator.apache.org
Subject: RE: Multiple threads updating/reading the same index in an ASP.NET
website. - IndexModifier

I won't SWEAR to it, but I think that in my coding experiments, when I
called the constructor of a
searcher, which takes a path to the index, while an IndexModifier had the
index open, the line
failed.

--- Digy <di...@gmail.com> wrote:

> 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:ctrager@yahoo.com] 
> 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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> > 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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> > > 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?
> > > 
> > > 
> > >       
> > > 
> > > 
> > 
> > 
> > 
> >       
> > 
> > 
> 
> 
> 
>       
> 
> 



      


RE: Multiple threads updating/reading the same index in an ASP.NET website. - IndexModifier

Posted by Corey Trager <ct...@yahoo.com>.
I won't SWEAR to it, but I think that in my coding experiments, when I called the constructor of a
searcher, which takes a path to the index, while an IndexModifier had the index open, the line
failed.

--- Digy <di...@gmail.com> wrote:

> 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:ctrager@yahoo.com] 
> 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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> > 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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> > > 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?
> > > 
> > > 
> > >       
> > > 
> > > 
> > 
> > 
> > 
> >       
> > 
> > 
> 
> 
> 
>       
> 
> 



      

RE: Multiple threads updating/reading the same index in an ASP.NET website. - IndexModifier

Posted by Digy <di...@gmail.com>.
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:ctrager@yahoo.com] 
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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> 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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> > 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?
> > 
> > 
> >       
> > 
> > 
> 
> 
> 
>       
> 
> 



      


RE: Multiple threads updating/reading the same index in an ASP.NET website. - IndexModifier

Posted by Corey Trager <ct...@yahoo.com>.
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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> 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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> > 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?
> > 
> > 
> >       
> > 
> > 
> 
> 
> 
>       
> 
> 



      

RE: Multiple threads updating/reading the same index in an ASP.NET website. - IndexModifier

Posted by Digy <di...@gmail.com>.
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:ctrager@yahoo.com] 
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 <di...@gmail.com> 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:ctrager@yahoo.com] 
> 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?
> 
> 
>       
> 
> 



      


RE: Multiple threads updating/reading the same index in an ASP.NET website. - IndexModifier

Posted by Corey Trager <ct...@yahoo.com>.
And, the same with IndexModifier, right?  I should have one single instance of it and all threads
use that same instance?

--- Digy <di...@gmail.com> 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:ctrager@yahoo.com] 
> 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?
> 
> 
>       
> 
> 



      

RE: Multiple threads updating/reading the same index in an ASP.NET website.

Posted by Corey Trager <ct...@yahoo.com>.
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?


--- Digy <di...@gmail.com> 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:ctrager@yahoo.com] 
> 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?
> 
> 
>       
> 
> 



      

RE: Multiple threads updating/reading the same index in an ASP.NET website.

Posted by Digy <di...@gmail.com>.
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:ctrager@yahoo.com] 
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?