/** Expert: attempts to delete by document ID, as long as * the provided reader is a near-real-time reader (from {@link * DirectoryReader#open(IndexWriter)}). If the * provided reader is an NRT reader obtained from this * writer, and its segment has not been merged away, then * the delete succeeds and this method returns a valid (> 0) sequence * number; else, it returns -1 and the caller must then * separately delete by Term or Query. * * <b>NOTE</b>: this method can only delete documents * visible to the currently open NRT reader. If you need * to delete documents indexed after opening the NRT * reader you must use {@link #deleteDocuments(Term...)}). */ public synchronized long tryDeleteDocument(IndexReader readerIn, int docID) throws IOException { // NOTE: DON'T use docID inside the closure return tryModifyDocument(readerIn, docID, (leafDocId, rld) -> { if (rld.delete(leafDocId)) { if (isFullyDeleted(rld)) { dropDeletedSegment(rld.info); checkpoint(); } // Must bump changeCount so if no other changes // happened, we still commit this change: changed(); } }); }
if (segState.rld.delete(docID)) { delCount++;
/** Expert: attempts to delete by document ID, as long as * the provided reader is a near-real-time reader (from {@link * DirectoryReader#open(IndexWriter)}). If the * provided reader is an NRT reader obtained from this * writer, and its segment has not been merged away, then * the delete succeeds and this method returns a valid (> 0) sequence * number; else, it returns -1 and the caller must then * separately delete by Term or Query. * * <b>NOTE</b>: this method can only delete documents * visible to the currently open NRT reader. If you need * to delete documents indexed after opening the NRT * reader you must use {@link #deleteDocuments(Term...)}). */ public synchronized long tryDeleteDocument(IndexReader readerIn, int docID) throws IOException { // NOTE: DON'T use docID inside the closure return tryModifyDocument(readerIn, docID, (leafDocId, rld) -> { if (rld.delete(leafDocId)) { if (isFullyDeleted(rld)) { dropDeletedSegment(rld.info); checkpoint(); } // Must bump changeCount so if no other changes // happened, we still commit this change: changed(); } }); }
synchronized(bufferedUpdatesStream) { rld.initWritableLiveDocs(); if (rld.delete(docID)) { final int fullDelCount = rld.info.getDelCount() + rld.getPendingDeleteCount(); if (fullDelCount == rld.info.info.maxDoc()) {
segState.any = true; if (segState.rld.delete(doc)) { delCount++;
synchronized(bufferedUpdatesStream) { rld.initWritableLiveDocs(); if (rld.delete(docID)) { final int fullDelCount = rld.info.getDelCount() + rld.getPendingDeleteCount(); if (fullDelCount == rld.info.info.maxDoc()) {
segState.any = true; if (segState.rld.delete(doc)) { delCount++;
if (segState.rld.delete(docID)) { delCount++;
holder.init(readerPool, merge, mergeState, true); holder.mergedDeletesAndUpdates.delete(holder.docMap.map(docUpto)); if (mergingFields != null) { // advance all iters beyond the deleted document skipDeletedDoc(updatesIters, j); holder.init(readerPool, merge, mergeState, true); holder.mergedDeletesAndUpdates.delete(holder.docMap.map(docUpto)); if (mergingFields != null) { // advance all iters beyond the deleted document skipDeletedDoc(updatesIters, j);
holder.init(readerPool, merge, mergeState, true); holder.mergedDeletesAndUpdates.delete(holder.docMap.map(docUpto)); if (mergingFields != null) { // advance all iters beyond the deleted document skipDeletedDoc(updatesIters, j); holder.init(readerPool, merge, mergeState, true); holder.mergedDeletesAndUpdates.delete(holder.docMap.map(docUpto)); if (mergingFields != null) { // advance all iters beyond the deleted document skipDeletedDoc(updatesIters, j);
state.rld.delete(docID);
state.rld.delete(docID);