How to implement a new backend
Storage
- Subclass whoosh.store.Storage.
- Storages must implement the following methods.
- whoosh.store.Storage.create_index() – create an object implementing the
whoosh.index.Index interface and returns it.
- whoosh.store.Storage.open_index() – returns an object implementing the
whoosh.index.Index interface.
- Storage may implement the following methods (the base class’s versions are no-ops).
- close() – closes any resources in use by the Storage object.
- optimize() – cleans up and/or compacts the data stored in the Storage object.
Index
- Subclass whoosh.index.Index.
- Indexes must implement the following methods.
- Indexes the require/support locking must implement the following methods.
- whoosh.index.Index.lock()
- whoosh.index.Index.unlock()
- Indexes that support deletion must implement the following methods.
- Indexes that require/support versioning/transactions may implement the following methods.
- Index may implement the following methods (the base class’s versions are no-ops).
IndexWriter
- Subclass whoosh.writing.IndexWriter.
- IndexWriters must implement the following methods.
- whoosh.reading.IndexWriter.add_document() –
- IndexWriters that support deletion must implement the following methods.
- IndexWriters that work as transactions must implement the following methods.
- whoosh.reading.IndexWriter.commit() – Save the additions/deletions done with
this IndexWriter to the main index, and release any resources used by the IndexWriter.
- whoosh.reading.IndexWriter.cancel() – Throw away any additions/deletions done
with this IndexWriter, and release any resources used by the IndexWriter.
DocReader
- Subclass whoosh.reading.DocReader.
- DocReaders must implement the following methods.
- whoosh.reading.DocReader.__getitem__() –
- whoosh.reading.DocReader.__iter__() –
- whoosh.reading.DocReader.doc_count_all() –
- whoosh.reading.DocReader.doc_count() –
- whoosh.reading.DocReader.field_length() –
- whoosh.reading.DocReader.doc_field_length() –
- whoosh.reading.DocReader.doc_field_lengths() –
- whoosh.reading.DocReader.vector() –
- whoosh.reading.DocReader.vector_as() –
- DocReaders may implement the following methods.
- whoosh.reading.DocReader.close() – closes any open resources associated with the
reader.
TermReader
- Subclass whoosh.reading.TermReader.
- Implement the following methods.
- whoosh.reading.TermReader.__contains__() – returns True if the given term tuple
(fieldid, text) is in this reader.
- whoosh.reading.TermReader.__iter__() –
- whoosh.reading.TermReader.iter_from() –
- whoosh.reading.TermReader.doc_frequency() –
- whoosh.reading.TermReader.frequency() –
- whoosh.reading.TermReader.doc_count_all() –
- whoosh.reading.TermReader.postings() –
- TermReaders may implement the following methods.
- whoosh.reading.TermReader.close() – closes any open resources associated with the
reader.