title: Lucene.NET is not deleting docs?
body: <p>I've probably gone through numerous S.O. posts on this issue, but I'm at a loss and can't figure out what the problem is. </p>
  
  <p>I can add and update docs to the index, but I cannot seem to successfully delete them. </p>
  
  <p>I'm using <code>Lucene.NET</code> v3.0.3</p>
  
  <p>I read one suggestion was to do a <em>query</em> using the same conditions and ensure I'm getting a result back. Well, I did so:</p>
  
  <p>First, I have a method that returns items in my database that have been marked as deleted</p>
  
  <pre><code>var deletedItems = VehicleController.GetDeleted(DateTime lastcheck);
  </code></pre>
  
  <p>Right now during testing, this includes a single item. I then iterate:</p>
  
  <pre><code>// This method returns my writer
  var indexWriter = LuceneController.GetWriter();
  
  // And my searcher
  var searcher = new IndexSearcher(indexWriter.GetReader());
  
  // And iterate over my items (just one for testing)
  foreach(var c in deletedItems) {
  
    // Here I'm testing by doing a query
    var query = new BooleanQuery();
    query.Add(new TermQuery(new Term("key", c.Guid.ToString())), Occur.MUST);
  
    // Let's see if it can find the record based on this
    var docs = searcher.Search(query, 1);
  
    var foundDoc = docs.FirstOrDefault();
  
    // Yep, we have one... let's get the full doc to be sure
    var actualDoc = searcher.Doc(foundDoc.Doc);
  
    // If I inspect actualDoc, it's the right one... I want to delete it.
    indexWriter.DeleteDocuments(query);
    indexWriter.Commit();
  
  }
  </code></pre>
  
  <p>I've tried to smash all the logic above so it's easier to read, but I've tried all kinds of methods... </p>
  
  <pre><code>indexWriter.Optimize();
  indexWriter.Flush(true, true, true);
  </code></pre>
  
  <p>If I watch the actual folder where everything is being stored, I can see filenames like <code>0_1.del</code> and stuff like that popup, which seems promising. </p>
  
  <p>I then read somewhere about a merge policy, but isn't that what <code>Flush</code> is supposed to do? </p>
  
  <p>Then read to try setting the optimize method to 1 max, and that still didn't work (i.e. <code>indexWriter.Optimize(1)</code>).</p>
  
  <p>So using the same query to fetch works, but deleting does not. Why? What else can I check? Does delete actually remove the item permanently or does it live on in some other manner until I completely delete the directory that's being used? Not understanding.</p>