I'm going through and updating my Lucene Boot Camp training for 2.9. In it, I have some code that shows the various ways you can do deletes.

In 2.4, the code worked fine, in 2.9 it now fails.  Here's the code:
public void testDeletions() throws Exception {
    log.info("----------------testDeletions()-------------");
    //we should have indexed already
    IndexReader reader = IndexReader.open(directory, false);
    assertTrue("reader is null and it shouldn't be", reader != null);
    Document doc = reader.document(0);
    assertTrue("doc is null and it shouldn't be", doc != null);
    reader.deleteDocument(0);
assertTrue(reader.isDeleted(0) + " does not equal: " + true, reader.isDeleted(0) == true);
    try {
doc = reader.document(0); //verify the document is not retrievable
      assertTrue(doc.toString(), false);
    } catch (IllegalArgumentException e) {

    }

    log.info("----------------end testDeletions()-------------");
  }

This is, of course, due to LUCENE-1708:

* LUCENE-1708 - IndexReader.document() no longer checks if the document is deleted. You can call IndexReader.isDeleted(n) prior to calling document(n).
    (Shai Erera via Mike McCandless)

However, it seems like this is a break in back-compat as it requires people to actively change their code. Granted, my test case is admittedly contrived, but I wonder if other people come across this. I understand that I'm not going to find (search) a deleted document so in most cases it's not a big deal, but plenty of people use Lucene as a document store, too, and may access documents directly such that their code may now well be broken.

Anyone against me moving the issue from the Runtime changes section to the Back Compat section?

-Grant


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

Reply via email to