I believe your docs are being deleted. It's just that
IndexWriter.docCount() does not count deleted docs. That method
matches IndexReader.maxDoc(), not IndexReader.numDocs().
If you open an IndexReader and call numDocs() does it reflect the
deletion?
Really I think we should add "maxDoc()" and "numDocs()" to
IndexWriter, and deprecate docCount() in favor of maxDoc(). I'll
open an issue.
The two indeed take very different routes for deletion. IndexModifier
closes its writer, opens a reader, and does the deletions with the
reader. These deletions are "immediate" in that the reader can tell
you how many docs just got deleted, but not committed until the
modifier closes its reader.
Whereas IndexWriter.deleteDocuments simply buffers up all terms and
periodically these are flushed in bulk to the index. Only closing the
IndexWriter ensures that the deletions are visible to a reader.
We are trying over time to move towards a read-only IndexReader, and
absorbing all write operations into IndexWriter.
Mike
Ulf Dittmer wrote:
Hello all-
While adapting some code to use IndexWriter instead of
IndexModifier (as indicated by the deprecation
warnings), I stumbled upon an issue that I at first
thought was a bug, but I'm sure it's only because I
don't fully understand how Lucene works.
Basically, I'm using the deleteDocuments(Term) method,
which works as expected in IndexModifier, but which
-for the very same Term- doesn't find and delete a
document in IndexWriter.
I've looked at the source of
IndexWriter.deleteDocuments and
IndexModifier.deleteDocuments, but they seem to go
about deleting documents in very different ways, so it
wasn't obvious to me what's going on.
The source of a short program that exhibits this
behavior is at
http://www.ulfdittmer.com/LuceneTest.java
I'd be grateful if someone could give me hint of
whether I'm using the API incorrectly, or what's going
on.
Thanks in advance,
Ulf
______________________________________________________________________
______________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://
mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]