How to implement a new backend

How to implement a new backend

How to implement a new backend

Index

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.
    • whoosh.reading.IndexReader.__contains__()
    • whoosh.reading.IndexReader.__iter__()
    • whoosh.reading.IndexReader.iter_from()
    • whoosh.reading.IndexReader.stored_fields()
    • whoosh.reading.IndexReader.doc_count_all()
    • whoosh.reading.IndexReader.doc_count()
    • whoosh.reading.IndexReader.doc_field_length()
    • whoosh.reading.IndexReader.field_length()
    • whoosh.reading.IndexReader.max_field_length()
    • whoosh.reading.IndexReader.postings()
    • whoosh.reading.IndexReader.has_vector()
    • whoosh.reading.IndexReader.vector()
    • whoosh.reading.IndexReader.doc_frequency()
    • whoosh.reading.IndexReader.frequency()
  • Backends that support deleting documents should implement the following methods.
    • whoosh.reading.IndexReader.has_deletions()
    • whoosh.reading.IndexReader.is_deleted()
  • Backends that support versioning should implement the following methods.
    • whoosh.reading.IndexReader.generation()
  • 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.