>From the 3.2.0 javadocs:

"Optimize is a fairly costly operation, so you should only do it if
your search performance really requires it. Many search applications
do fine never calling optimize."


See the FAQ and javadocs on searchers and writers for thread safety info.

One thing that optimize does do is clear out deleted documents.  Could
that be relevant to your test failure?  If so, there is an
expungeDeletes() method you could maybe use instead.


--
Ian.

On Wed, Jun 22, 2011 at 8:24 PM, Hiller, Dean  x66079
<dean.hil...@broadridge.com> wrote:
> I read that in a lot of cases IndexWriter.optimize does not have to be called.
>
> I then deleted it and my junit test case broke because results were coming 
> back in the query that were not supposed to be coming back :(.  I think 
> everything is single tested.  Maybe I should write a more raw junit test 
> first? But I thought I would ask what exactly is optimize doing and is Lucene 
> thread safe...I read that it was somewhere(but also read elsewhere it wasn't).
>
> I kind of assumed my IndexWriters are not thread safe, but my IndexSearcher 
> could be running while another thread is using the IndexWriter, right?
>
> (Of course, while my unit test is single threaded and failed with just this 
> one line change, our production system will be multithreaded which is why I 
> ask).
>
> Thanks,
> Dean

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

Reply via email to