setSoftDeletesField

Sets the soft-deletes field. A soft-delete field in Lucene is a doc-values field that marks a document as soft-deleted, if a document has at least one value in that field. If a document is marked as soft-deleted, the document is treated as if it has been hard-deleted through the IndexWriter API (IndexWriter.deleteDocuments. Merges will reclaim soft-deleted as well as hard-deleted documents, and index readers obtained from the IndexWriter will reflect all deleted documents in its live docs. If soft-deletes are used, documents must be indexed via IndexWriter.softUpdateDocument. Deletes are applied via IndexWriter.updateDocValues.

Soft deletes allow to retain documents across merges if the merge policy modifies the live docs of a merge reader. SoftDeletesRetentionMergePolicy for instance allows to specify an arbitrary query to mark all documents that should survive the merge. This can be used, for example, to keep all document modifications for a certain time interval or the last N operations if some kind of sequence ID is available in the index.

Currently there is no API support to un-delete a soft-deleted document. In order to un-delete a document, it must be re-indexed using IndexWriter.softUpdateDocument.

The default value for this is null, which disables soft-deletes. If soft-deletes are enabled, documents can still be hard-deleted. Hard-deleted documents won't be considered as soft-deleted even if they have a value in the soft-deletes field.

See also

.getSoftDeletesField