[ 
https://issues.apache.org/jira/browse/LUCENE-1705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12722021#action_12722021
 ] 

Tim Smith commented on LUCENE-1705:
-----------------------------------

My use case is like so:

* IndexReader opened against old index (the last committed index)
* user requests "clearing the index" (for whatever reason, up to them to 
decide) 
** this will close the current IndexWriter and reopen with create=true (ideally 
this would just call writer.deleteAll())
** IndexWriter.init() writes out new segments.gen file referencing no segments 
with create=true (old segments are not yet deleted as IndexReader is still open 
for them)
** NOTE: new IndexReader not yet opened because they haven't said "commit" yet
** (previous commit will still be the "live" index seen by searches - obviously 
this means disk is not reclaimed yet)
* user may then feed new documents, or not, (up to them)
* user will then eventually say commit
* new IndexReader will be opened, which should only contain documents added 
since the "deleteAll()" operation

Ideally, i want to perform this delete all operation very efficiently without 
needing to reopen an IndexWriter 
The rollback() call would possibly slightly optimize what i am currently doing, 
but even better still would be a highly efficient deleteAll() method (as all 
the semantics of this operation would be handled nicely (without jumping 
through hoops to clear the index))

Creating a new IndexWriter in the same directory with create=true works like a 
champ, (existing IndexReaders still see the previous commit)
just want do avoid the IndexWriter.close() call



> Add deleteAllDocuments() method to IndexWriter
> ----------------------------------------------
>
>                 Key: LUCENE-1705
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1705
>             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: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to