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 Eran Sevi <er...@gmail.com> on 2008/09/25 11:08:48 UTC
Optimizing while readers are open
Hi,
I have the following scenario using Lucene 2.1
1. Open reader on index to perform some searches.
2. Use reader to check if index is optimized.
2. Open writer and run optimize()
3. Close old reader and open a new reader for further searches.
I expected that after closing the old reader , the index snapshot that was
created because of the optimize would be removed, but that doesn't happen.
I remain with X2 index size even though there are not open readers.
If I open a new reader, I guess it uses the new optimized segment because
isOptimized() returns true.
I don't want to close all the readers/searchers before optimizing because it
is time consuming and I want to allow searching the index in the meantime by
using the same old reader that was opened before the optimization began.No
new readers are opened while the index is optimized.
What am I missing in this scenario?
How can I clear the old redundant files that were used by the reader?
Thanks in advance,
Eran.
Re: Optimizing while readers are open
Posted by Michael McCandless <lu...@mikemccandless.com>.
Eran Sevi wrote:
> I'm using Windows and it worked just fine, although the procedure is
> a bit
> awkward. Why do I have to open a new writer? closing the current one
> (after
> switching readers) isn't enough? is it because of deleted documents
> that
> need to be updated?
It's because Windows doesn't let you delete a file that's open (not
due to deleted documents).
> Do you know if it's different in more advanced versions than 2.1 ?
In fact, it is: as of 2.3, IndexWriter will try to delete unreferenced
files during close(). So once you upgrade you won't need to open &
close a new IndexWriter.
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Optimizing while readers are open
Posted by Eran Sevi <er...@gmail.com>.
Thanks Mike,
I'm using Windows and it worked just fine, although the procedure is a bit
awkward. Why do I have to open a new writer? closing the current one (after
switching readers) isn't enough? is it because of deleted documents that
need to be updated?
Do you know if it's different in more advanced versions than 2.1 ?
Eran.
On Thu, Sep 25, 2008 at 12:23 PM, Michael McCandless <
lucene@mikemccandless.com> wrote:
>
> Are you on Windows?
>
> If so, you'll need to then open & close a new IndexWriter after the old
> reader has switched to the optimized index. That will delete the old files.
>
> On other OSs, which usually implement "delete on last close", the disk
> space should be automatically freed up once you close the old reader.
>
> Mike
>
>
> Eran Sevi wrote:
>
> Hi,
>>
>> I have the following scenario using Lucene 2.1
>>
>> 1. Open reader on index to perform some searches.
>> 2. Use reader to check if index is optimized.
>> 2. Open writer and run optimize()
>> 3. Close old reader and open a new reader for further searches.
>>
>> I expected that after closing the old reader , the index snapshot that was
>> created because of the optimize would be removed, but that doesn't happen.
>> I remain with X2 index size even though there are not open readers.
>>
>> If I open a new reader, I guess it uses the new optimized segment because
>> isOptimized() returns true.
>> I don't want to close all the readers/searchers before optimizing because
>> it
>> is time consuming and I want to allow searching the index in the meantime
>> by
>> using the same old reader that was opened before the optimization began.No
>> new readers are opened while the index is optimized.
>>
>> What am I missing in this scenario?
>> How can I clear the old redundant files that were used by the reader?
>>
>> Thanks in advance,
>> Eran.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
Re: Optimizing while readers are open
Posted by Michael McCandless <lu...@mikemccandless.com>.
Are you on Windows?
If so, you'll need to then open & close a new IndexWriter after the
old reader has switched to the optimized index. That will delete the
old files.
On other OSs, which usually implement "delete on last close", the disk
space should be automatically freed up once you close the old reader.
Mike
Eran Sevi wrote:
> Hi,
>
> I have the following scenario using Lucene 2.1
>
> 1. Open reader on index to perform some searches.
> 2. Use reader to check if index is optimized.
> 2. Open writer and run optimize()
> 3. Close old reader and open a new reader for further searches.
>
> I expected that after closing the old reader , the index snapshot
> that was
> created because of the optimize would be removed, but that doesn't
> happen.
> I remain with X2 index size even though there are not open readers.
>
> If I open a new reader, I guess it uses the new optimized segment
> because
> isOptimized() returns true.
> I don't want to close all the readers/searchers before optimizing
> because it
> is time consuming and I want to allow searching the index in the
> meantime by
> using the same old reader that was opened before the optimization
> began.No
> new readers are opened while the index is optimized.
>
> What am I missing in this scenario?
> How can I clear the old redundant files that were used by the reader?
>
> Thanks in advance,
> Eran.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org