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 Zhou Qi <zh...@gmail.com> on 2007/12/27 14:59:00 UTC

IndexReader open problem?

Hi all,

  I encounter a strange probelm. To improve performance, I open the
indexreader at the start time and reuse it in later search. I have another
process running to do online indexing. The search service and indexing
service is accessing the same index folder. But I found out the search
service only returns old documents. That is to say, my index reader did not
refresh the index folder for up-to-date index. If it acutally works like
that in lucene, should I try to open the index to init the indexreader
everytime I do search?

Thanks

Re: IndexReader open problem?

Posted by Zhou Qi <zh...@gmail.com>.
Eric,

Thanks for your advise. I implement a version count to sych the index and
search.

2007/12/27, Erick Erickson <er...@gmail.com>:
>
> If you search the mail archives, you'll find many discussions
> of the fact that when you open an index reader, it takes a
> snapshot of the index and subsequent modifications to the
> index are not available until the searcher is closed and re-opened.
>
> It is NOT a good idea to open a new reader every time you search,
> as this is an expensive operation. You have to reach some
> compromise between absolutely up-to-date results and how
> much closing/opening of your readers you can afford.
>
> A bunch of approaches are discussed in the archives, so one of
> those discussions may parallel your situation. Otherwise, you
> need to give us some idea of your constraints before anyone can
> suggest an approach.
>
> Best
> Erick
>
> On Dec 27, 2007 8:59 AM, Zhou Qi <zh...@gmail.com> wrote:
>
> > Hi all,
> >
> >  I encounter a strange probelm. To improve performance, I open the
> > indexreader at the start time and reuse it in later search. I have
> another
> > process running to do online indexing. The search service and indexing
> > service is accessing the same index folder. But I found out the search
> > service only returns old documents. That is to say, my index reader did
> > not
> > refresh the index folder for up-to-date index. If it acutally works like
> > that in lucene, should I try to open the index to init the indexreader
> > everytime I do search?
> >
> > Thanks
> >
>

Re: IndexReader open problem?

Posted by Erick Erickson <er...@gmail.com>.
If you search the mail archives, you'll find many discussions
of the fact that when you open an index reader, it takes a
snapshot of the index and subsequent modifications to the
index are not available until the searcher is closed and re-opened.

It is NOT a good idea to open a new reader every time you search,
as this is an expensive operation. You have to reach some
compromise between absolutely up-to-date results and how
much closing/opening of your readers you can afford.

A bunch of approaches are discussed in the archives, so one of
those discussions may parallel your situation. Otherwise, you
need to give us some idea of your constraints before anyone can
suggest an approach.

Best
Erick

On Dec 27, 2007 8:59 AM, Zhou Qi <zh...@gmail.com> wrote:

> Hi all,
>
>  I encounter a strange probelm. To improve performance, I open the
> indexreader at the start time and reuse it in later search. I have another
> process running to do online indexing. The search service and indexing
> service is accessing the same index folder. But I found out the search
> service only returns old documents. That is to say, my index reader did
> not
> refresh the index folder for up-to-date index. If it acutally works like
> that in lucene, should I try to open the index to init the indexreader
> everytime I do search?
>
> Thanks
>