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 "Boeckli, Dominique" <do...@eds.com> on 2007/07/06 16:16:23 UTC

document delete after reader.close()

Hello,

i have following problem:

I have written a Lucene JCA Connector which also taking care of the
index maintenance. From time to time the connector
is called (time initiated) and verifies if the index still is in synch
with the filesystem (deleted, added or updated documents).
If something changes, for example when a file was deleted, then the
documents are delete from the index as well:

IndexReader reader = getIndexReader();
	for (int i=0; i<documentsToDelete.size();i++) {
		String path = documentsToDelete.get(i).getPath();
		Term term = new Term(FileDocument.PATH, path);
		reader.deleteDocuments(term);
            count++;
	}
reader.close();

The problem is that the document is not deleted after the close. The
document is only deleted after a while
when the jca connector was recreated (deleted from the jca pool), which
means only after the thread has
terminated.

strange, did i missed something.

Please explain to me if i did something wrong

many thanks

Dominique

Re: document delete after reader.close()

Posted by Erick Erickson <er...@gmail.com>.
Glad that worked for you. But one caution, don't be over-anxious to
close readers since opening a reader is an expensive operation and
will affect performance. So you should close/re-open them only when
you know you've modified your index.... But if you're not experiencing
performance issues, you probably don't care <G>......

Best
Erick

On 7/9/07, Boeckli, Dominique <do...@eds.com> wrote:
>
> Hi Erick,
>
> thanks for your help, this was the solution: Connectors are pooled
> resources and i kept always the same reader for all
> connections: bad idea. They never see updates in the index for that
> reason. Now i close the readers and everything
> is ok.
>
> Best
>
> Dominique
>
> -----Original Message-----
> From: Erick Erickson [mailto:erickerickson@gmail.com]
> Sent: Friday, July 06, 2007 04:38 PM
> To: java-user@lucene.apache.org
> Subject: Re: document delete after reader.close()
>
> Warning, I don't know much about JCA Connector.
>
> That said, index modifications aren't visible to a searcher until the
> *searcher* is closed and re-opened. Which sounds suspiciously like what
> would happen when the thread terminates.
>
> This may be totally off base, but sounds like a place to look...
>
> Best
> Erick
>
> On 7/6/07, Boeckli, Dominique <do...@eds.com> wrote:
> >
> >
> > Hello,
> >
> > i have following problem:
> >
> > I have written a Lucene JCA Connector which also taking care of the
> > index maintenance. From time to time the connector is called (time
> > initiated) and verifies if the index still is in synch with the
> > filesystem (deleted, added or updated documents).
> > If something changes, for example when a file was deleted, then the
> > documents are delete from the index as well:
> >
> > IndexReader reader = getIndexReader();
> >         for (int i=0; i<documentsToDelete.size();i++) {
> >                 String path = documentsToDelete.get(i).getPath();
> >                 Term term = new Term(FileDocument.PATH, path);
> >                 reader.deleteDocuments(term);
> >             count++;
> >         }
> > reader.close();
> >
> > The problem is that the document is not deleted after the close. The
> > document is only deleted after a while when the jca connector was
> > recreated (deleted from the jca pool), which means only after the
> > thread has terminated.
> >
> > strange, did i missed something.
> >
> > Please explain to me if i did something wrong
> >
> > many thanks
> >
> > Dominique
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

RE: document delete after reader.close()

Posted by "Boeckli, Dominique" <do...@eds.com>.
Hi Erick,

thanks for your help, this was the solution: Connectors are pooled
resources and i kept always the same reader for all 
connections: bad idea. They never see updates in the index for that
reason. Now i close the readers and everything
is ok.

Best

Dominique  

-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com] 
Sent: Friday, July 06, 2007 04:38 PM
To: java-user@lucene.apache.org
Subject: Re: document delete after reader.close()

Warning, I don't know much about JCA Connector.

That said, index modifications aren't visible to a searcher until the
*searcher* is closed and re-opened. Which sounds suspiciously like what
would happen when the thread terminates.

This may be totally off base, but sounds like a place to look...

Best
Erick

On 7/6/07, Boeckli, Dominique <do...@eds.com> wrote:
>
>
> Hello,
>
> i have following problem:
>
> I have written a Lucene JCA Connector which also taking care of the 
> index maintenance. From time to time the connector is called (time 
> initiated) and verifies if the index still is in synch with the 
> filesystem (deleted, added or updated documents).
> If something changes, for example when a file was deleted, then the 
> documents are delete from the index as well:
>
> IndexReader reader = getIndexReader();
>         for (int i=0; i<documentsToDelete.size();i++) {
>                 String path = documentsToDelete.get(i).getPath();
>                 Term term = new Term(FileDocument.PATH, path);
>                 reader.deleteDocuments(term);
>             count++;
>         }
> reader.close();
>
> The problem is that the document is not deleted after the close. The 
> document is only deleted after a while when the jca connector was 
> recreated (deleted from the jca pool), which means only after the 
> thread has terminated.
>
> strange, did i missed something.
>
> Please explain to me if i did something wrong
>
> many thanks
>
> Dominique
>

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


Re: document delete after reader.close()

Posted by Erick Erickson <er...@gmail.com>.
Warning, I don't know much about JCA Connector.

That said, index modifications aren't visible to a searcher
until the *searcher* is closed and re-opened. Which sounds
suspiciously like what would happen when the thread
terminates.

This may be totally off base, but sounds like a place to look...

Best
Erick

On 7/6/07, Boeckli, Dominique <do...@eds.com> wrote:
>
>
> Hello,
>
> i have following problem:
>
> I have written a Lucene JCA Connector which also taking care of the
> index maintenance. From time to time the connector
> is called (time initiated) and verifies if the index still is in synch
> with the filesystem (deleted, added or updated documents).
> If something changes, for example when a file was deleted, then the
> documents are delete from the index as well:
>
> IndexReader reader = getIndexReader();
>         for (int i=0; i<documentsToDelete.size();i++) {
>                 String path = documentsToDelete.get(i).getPath();
>                 Term term = new Term(FileDocument.PATH, path);
>                 reader.deleteDocuments(term);
>             count++;
>         }
> reader.close();
>
> The problem is that the document is not deleted after the close. The
> document is only deleted after a while
> when the jca connector was recreated (deleted from the jca pool), which
> means only after the thread has
> terminated.
>
> strange, did i missed something.
>
> Please explain to me if i did something wrong
>
> many thanks
>
> Dominique
>