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 Stefano Buliani <st...@meganexus.com> on 2005/06/14 13:29:24 UTC

problem with IndexSearcher

Hi,
I'm currently using Lucene on a java web site; I've a class containing a
synchronized method that runs all the update on the index, this class
also contains a method (not synchronized) called getSearcher which
returns an IndexSearcher object.

I'm using the singleton pattern for this class so there can be only one
instance.
When I update the index I close() the IndexSearcher object in the class,
run the update then create a new IndexSearcher.

This is my problem:
I add a document to the index and search for I can find it.
If I remove the document and search for it again it doesn't find
anything (correct behaviour).
If I add again the same document to the index I can't find it until I
restart the application server (I should be able to find it).

I've noticed that if I create a new IndexSearcher every time they call
the method getSearcher instead of returning the one already instanced it
works fine, that's strange because I create a new IndexSearcher every
time I run the synchronized update method.
Any suggestion?

Regards,
	Stefano
 



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


Re: problem with IndexSearcher

Posted by Tony Schwartz <to...@simpleobjects.com>.
It appears you have answered your own question.  The problem seems to be in your code. 
Without seeing it though, how can we help?

Tony Schwartz
tony@simpleobjects.com
"What we need is more cowbell."


> Hi,
> I'm currently using Lucene on a java web site; I've a class containing a
> synchronized method that runs all the update on the index, this class
> also contains a method (not synchronized) called getSearcher which
> returns an IndexSearcher object.
>
> I'm using the singleton pattern for this class so there can be only one
> instance.
> When I update the index I close() the IndexSearcher object in the class,
> run the update then create a new IndexSearcher.
>
> This is my problem:
> I add a document to the index and search for I can find it.
> If I remove the document and search for it again it doesn't find
> anything (correct behaviour).
> If I add again the same document to the index I can't find it until I
> restart the application server (I should be able to find it).
>
> I've noticed that if I create a new IndexSearcher every time they call
> the method getSearcher instead of returning the one already instanced it
> works fine, that's strange because I create a new IndexSearcher every
> time I run the synchronized update method.
> Any suggestion?
>
> Regards,
> 	Stefano
>
>
>
>
> ---------------------------------------------------------------------
> 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