How to implement a new backend
Index
- Subclass whoosh.index.Index.
- Indexes must implement the following methods.
- Indexes that 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.
- Backends 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.
IndexReader
- Subclass whoosh.reading.IndexReader.
- IndexReaders must implement the following methods.
- Backends that support deleting documents should implement the following
methods.
- Backends that support versioning should implement the following methods.
- If the IndexReader object does not keep the schema in the self.schema
attribute, it needs to override the following methods.
- whoosh.reading.IndexReader.field()
- whoosh.reading.IndexReader.field_names()
- whoosh.reading.IndexReader.scorable_names()
- whoosh.reading.IndexReader.vector_names()
- IndexReaders may implement the following methods.
- whoosh.reading.DocReader.close() – closes any open resources associated with the
reader.
Matcher
The whoosh.reading.IndexReader.postings() method returns a
whoosh.matching.Matcher object. You will probably need to implement
a custom Matcher class for reading from your posting lists.
- Subclass whoosh.matching.Matcher.
- Implement the following methods at minimum.
- Depending on the implementation, you may implement the following methods
more efficiently.
- If the implementation supports quality, you should implement the following
methods.