whoosh
whoosh copied to clipboard
[RFC] Give SegmentWriter a cachable Searcher
When repeatedly calling update_document()
, each call instantiates a Searcher
, which is expensive. The SegmentWriter
already has a write lock on the index, so if the conditions are right, let's cache a Searcher
, override its close()
method to keep it open, and close it on _finish()
if it's around.
I think this is safe, but I don't know enough about whoosh to be certain. All tests are still passing, and I didn't break any django-haystack tests with this change either.