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

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.

Table Of Contents

Previous topic

Technical notes

Next topic

filedb notes

This Page