title: Lucene .Net optimization process
body: <p>I am creating an index using Lucene .Net 2.9.2. After a lot of indexing, the index has many segments and deleted documents, so I am calling Optimize(numSegmets) on the IndexWriter.</p>
  
  <p>The index's segments count is indeed reduced to the value of <em>numSegmets</em>, but it still has deletions... doesnt a call to Optimize should also remove all deleted documents?</p>
  
  <p>My question is very important so I could know if this is how Lucene works or maybe I have some bug...</p>
  
  <p>Edit:
  here is my code snippet:</p>
  
  <pre><code>IndexWriter writer = new IndexWriter(/*open writer from index directroy*/);
  writer.Optimize(5);
  writer.Commit();
  
  bool hasDeletions = writer.HasDeletions();
  </code></pre>
  
  <p><em>hasDeletions</em> is true, while I was expecting it would be false...</p>