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 Yonghui Zhao <zh...@gmail.com> on 2014/02/13 16:14:34 UTC

simple question about index reader

Hi,

I am new to lucene and I get a simple question about index reader.

If I open a DirectoryReader say reader1 based on a disk directory, then the
lucene index directory is changed, to get new result I need get a new
DirectoryReader.

Suppose reader1 will get the result before the change forever.

I am wondering how lucene can guarantee reader1's result is not changed.

If I delete all docs from the folder after reader1 is opened,  after
optimize the directory should be empty now, how can reader1 still get old
result?

Re: simple question about index reader

Posted by Michael McCandless <lu...@mikemccandless.com>.
The reader holds all the underlying files still open, and relies on
the filesystem to "protect" still-open files that are deleted.

Windows does this by refusing to allow deletion.  Unix does it by
keeping the file bytes available on disk but removing the directory
entry ("delete on last close").

Mike McCandless

http://blog.mikemccandless.com


On Thu, Feb 13, 2014 at 10:14 AM, Yonghui Zhao <zh...@gmail.com> wrote:
> Hi,
>
> I am new to lucene and I get a simple question about index reader.
>
> If I open a DirectoryReader say reader1 based on a disk directory, then the
> lucene index directory is changed, to get new result I need get a new
> DirectoryReader.
>
> Suppose reader1 will get the result before the change forever.
>
> I am wondering how lucene can guarantee reader1's result is not changed.
>
> If I delete all docs from the folder after reader1 is opened,  after
> optimize the directory should be empty now, how can reader1 still get old
> result?

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