You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Siraj Haider <si...@jobdiva.com> on 2016/12/14 18:05:50 UTC

RE: IndexWriter and IndexReader in a shared environment

Hi Mike,
You said "periodically calling IW.commit when you need durability". Does it mean that if the program dies without calling the IW.commit() all the index changes would be lost that were not commited?

------
Regards
-Siraj Haider
(212) 306-0154

-----Original Message-----
From: Michael McCandless [mailto:lucene@mikemccandless.com]
Sent: Thursday, July 07, 2016 8:52 AM
To: Lucene Users <ja...@lucene.apache.org>; myshareit@gmail.com
Subject: Re: IndexWriter and IndexReader in a shared environment

The API is pretty simple.

Create IndexWriter and leave it open forever, using it to index/delete documents, and periodically calling IW.commit when you need durability.

Create a SearcherManager, passing it the IndexWriter, and use it per-search to acquire/release the searcher.  Periodically (ideally from a separate
thread) call SM.maybeRefresh so the searcher sees the latest indexing changes.

Mike McCandless

http://blog.mikemccandless.com

On Tue, Jul 5, 2016 at 9:36 AM, Desteny Child <my...@gmail.com> wrote:

> Hi,
>
> In my Spring Boot application I have implemented 2 API endpoints - one
> for Lucene(I use 5.2.1) document indexing and another one for searching.
>
> Right now I open every time on each request IndexWriter and IndexReader.
> With a big index it works pretty slow.
>
> I know that there is a possibility to use single IndexWriter  and
> IndexReader in a shared environment. There is SearcherManager or
> something like this for this purpose.
>
> I can't find a good example for this for Lucene 5. Could you please
> share with me this example ?
>
> Thanks in advance,
> Alex
>

________________________________

This electronic mail message and any attachments may contain information which is privileged, sensitive and/or otherwise exempt from disclosure under applicable law. The information is intended only for the use of the individual or entity named as the addressee above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution (electronic or otherwise) or forwarding of, or the taking of any action in reliance on, the contents of this transmission is strictly prohibited. If you have received this electronic transmission in error, please notify us by telephone, facsimile, or e-mail as noted above to arrange for the return of any electronic mail or attachments. Thank You.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: IndexWriter and IndexReader in a shared environment

Posted by Michael McCandless <lu...@mikemccandless.com>.
Since the last time you called IW.commit, yes.

IW.commit also determines visibility to IndexReaders opened on that
same directory.

Mike McCandless

http://blog.mikemccandless.com


On Wed, Dec 14, 2016 at 1:05 PM, Siraj Haider <si...@jobdiva.com> wrote:
> Hi Mike,
> You said "periodically calling IW.commit when you need durability". Does it mean that if the program dies without calling the IW.commit() all the index changes would be lost that were not commited?
>
> ------
> Regards
> -Siraj Haider
> (212) 306-0154
>
> -----Original Message-----
> From: Michael McCandless [mailto:lucene@mikemccandless.com]
> Sent: Thursday, July 07, 2016 8:52 AM
> To: Lucene Users <ja...@lucene.apache.org>; myshareit@gmail.com
> Subject: Re: IndexWriter and IndexReader in a shared environment
>
> The API is pretty simple.
>
> Create IndexWriter and leave it open forever, using it to index/delete documents, and periodically calling IW.commit when you need durability.
>
> Create a SearcherManager, passing it the IndexWriter, and use it per-search to acquire/release the searcher.  Periodically (ideally from a separate
> thread) call SM.maybeRefresh so the searcher sees the latest indexing changes.
>
> Mike McCandless
>
> http://blog.mikemccandless.com
>
> On Tue, Jul 5, 2016 at 9:36 AM, Desteny Child <my...@gmail.com> wrote:
>
>> Hi,
>>
>> In my Spring Boot application I have implemented 2 API endpoints - one
>> for Lucene(I use 5.2.1) document indexing and another one for searching.
>>
>> Right now I open every time on each request IndexWriter and IndexReader.
>> With a big index it works pretty slow.
>>
>> I know that there is a possibility to use single IndexWriter  and
>> IndexReader in a shared environment. There is SearcherManager or
>> something like this for this purpose.
>>
>> I can't find a good example for this for Lucene 5. Could you please
>> share with me this example ?
>>
>> Thanks in advance,
>> Alex
>>
>
> ________________________________
>
> This electronic mail message and any attachments may contain information which is privileged, sensitive and/or otherwise exempt from disclosure under applicable law. The information is intended only for the use of the individual or entity named as the addressee above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution (electronic or otherwise) or forwarding of, or the taking of any action in reliance on, the contents of this transmission is strictly prohibited. If you have received this electronic transmission in error, please notify us by telephone, facsimile, or e-mail as noted above to arrange for the return of any electronic mail or attachments. Thank You.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org