mchaput / whoosh

Pure-Python full-text search library
Other
569 stars 69 forks source link

[RFC] Give SegmentWriter a cachable Searcher #15

Open asedeno opened 3 years ago

asedeno commented 3 years ago

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.