Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move IndexReader.delete functionality to IndexWriter [LUCENE-273] #1351

Closed
asfimport opened this issue Sep 8, 2004 · 1 comment
Closed

Comments

@asfimport
Copy link

I propose moving the functionality of deleting a document from the index from
IndexReader to IndexWriter, not only because because it is misleading that a
reader modifies the index, but also because of the following problem:

I have a website index, that should be updated but that should also be available
for searching while updating. So I open an IndexReader for searching the index
for a specific document and for deleting an outdated document from the index and
I open an IndexWriter to add updated documents to the index. But there is a
conflict between the locks of those two instances. If I want to update a
document, I have to close the IndexWriter (because otherwise IndexReader could
not obtain the lock for writing to the index) and the IndexReader (because it
would complain if the index was modified since opening the reader). Then I have
to create a new reader to delete the document from the index, and I have to
close this reader as it does not release the write lock after deleting a
document, so I would not be able to open an IndexWriter. And now I can open a
fresh IndexWriter for adding the new document again and a fresh IndexReader for
searching the index for the next document.

You see, in the worst case (every document has been modified) the program is
only opening and closing readers and writers all the time.

If the IndexWriter deleted documents from the index, only this instance would
need a write lock and I could only use one IndexReader and one IndexWriter for
updating the whole index.

If you know a better way to update the index, then let me know.

Tilman Giese


Migrated from LUCENE-273 by Tilman Giese, resolved May 27 2006
Environment:

Operating System: other
Platform: Other
@asfimport
Copy link
Author

Christoph Goller (migrated from JIRA)

Having delete functionality in IndexReader and not in IndexWriter is a design
decision that cannot be changed easily. For an explanation and for a discussion
on updating of documents see developer list around July 16, subject:
"Deleting a document with an IndexWriter open".
.
Christoph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant