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 Dan Liu <dl...@tridsys.com> on 2005/12/08 17:23:49 UTC

delete and optimize

Hi,

 

What is the difference between following approaches?

 

Approach1

1)     open IndexWriter and index documents

2)     optimize the indexWriter and close the indexWriter

3)     open the IndexReader and delete some documents from the same
index

4)     close the IndexReader

 

Approach2

1)     open IndexWriter and index documents

2)     close the IndexWriter

3)     open the IndexReader and delete some documents from the same
index

4)     close the IndexReader

5)     open the IndexWriter again

6)     optimize the indexWriter and close the indexWriter

 

The Approach1 is definitely faster than Approach2. The difference is
that the Approach1 does not renumber the document nubmer. While with the
Approach2, the document nubmer reflects the renumbered doucements. In
other words, that reader.maxDoc() gives different result between
Approach1 and 2.

 

Since the optimize only affects the search speed, will I have any
performance diffenece between these approaches while searching? (note:
the documents are actually deleted when IndexReader is closed)

 

Thanks /dan