Our current code in the Lucene backend deletes only the root document, but leaves nested documents in the index.
That's because we use the __HSEARCH_id field to designate nested documents to delete, but nested documents to not have that field. Instead, they have a __HSEARCH_root_id field, and that field is not even indexed.
Maybe we should use the same ID field for nested documents?
I managed to check that locally using luke, but I believe we could design an automated test that creates a document with nested documents, deletes it, then recreates it without nested documents. The nested documents will magically still be matched when searching, which is an evidence there is a bug.
We should also check updates, since they rely on the same principle.