lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (JIRA)" <>
Subject [jira] Commented: (LUCENE-1705) Add deleteAllDocuments() method to IndexWriter
Date Sat, 20 Jun 2009 11:04:07 GMT


Michael McCandless commented on LUCENE-1705:

This should be simple to implement, by taking the logic that's now in IndexWriter's init method
(under the {{if (create) {}}) and pulling out into a separate method.

>From IndexWriter's standpoint, this is just another commit, on equal footing with all
prior commits even though it up and deleted all segments.  So eg a deletion policy could choose
to keep those past commits around, IndexReaders can open those past commits, etc.

One good functional gain by offering this method is it could be done within a single IndexWriter
transaction.  Ie you could deleteAll, make further changes, etc., but then change your mind
and rollback the entire transaction.  Whereas, requiring if you close & re-open the writer
with create=true, you've necessarily committed the change to the index.

So I don't think we should implicitly do a commit() from within deleteAll(); I think the user
should call commit() on their own.

> Add deleteAllDocuments() method to IndexWriter
> ----------------------------------------------
>                 Key: LUCENE-1705
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Wish
>          Components: Index
>    Affects Versions: 2.4
>            Reporter: Tim Smith
> Ideally, there would be a deleteAllDocuments() or clear() method on the IndexWriter
> This method should have the same performance and characteristics as:
> * currentWriter.close()
> * currentWriter = new IndexWriter(..., create=true,...)
> This would greatly optimize a delete all documents case. Using deleteDocuments(new MatchAllDocsQuery())
could be expensive given a large existing index.
> IndexWriter.deleteAllDocuments() should have the same semantics as a commit(), as far
as index visibility goes (new IndexReader opening would get the empty index)
> I see this was previously asked for in LUCENE-932, however it would be nice to finally
see this added such that the IndexWriter would not need to be closed to perform the "clear"
as this seems to be the general recommendation for working with an IndexWriter now
> deleteAllDocuments() method should:
> * abort any background merges (they are pointless once a deleteAll has been received)
> * write new segments file referencing no segments
> This method would remove one of the final reasons i would ever need to close an IndexWriter
and reopen a new one 

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message