1==============================
2How to implement a new backend
3==============================
4
5Index
6=====
7
8* Subclass :class:`whoosh.index.Index`.
9
10* Indexes must implement the following methods.
11
12  * :meth:`whoosh.index.Index.is_empty`
13
14  * :meth:`whoosh.index.Index.doc_count`
15
16  * :meth:`whoosh.index.Index.reader`
17
18  * :meth:`whoosh.index.Index.writer`
19
20* Indexes that require/support locking must implement the following methods.
21
22  * :meth:`whoosh.index.Index.lock`
23
24  * :meth:`whoosh.index.Index.unlock`
25
26* Indexes that support deletion must implement the following methods.
27
28  * :meth:`whoosh.index.Index.delete_document`
29
30  * :meth:`whoosh.index.Index.doc_count_all` -- if the backend has delayed
31    deletion.
32
33* Indexes that require/support versioning/transactions *may* implement the following methods.
34
35  * :meth:`whoosh.index.Index.latest_generation`
36
37  * :meth:`whoosh.index.Index.up_to_date`
38
39  * :meth:`whoosh.index.Index.last_modified`
40
41* Index *may* implement the following methods (the base class's versions are no-ops).
42
43  * :meth:`whoosh.index.Index.optimize`
44
45  * :meth:`whoosh.index.Index.close`
46
47
48IndexWriter
49===========
50
51* Subclass :class:`whoosh.writing.IndexWriter`.
52
53* IndexWriters must implement the following methods.
54
55  * :meth:`whoosh.writing.IndexWriter.add_document`
56
57  * :meth:`whoosh.writing.IndexWriter.add_reader`
58
59* Backends that support deletion must implement the following methods.
60
61  * :meth:`whoosh.writing.IndexWriter.delete_document`
62
63* IndexWriters that work as transactions must implement the following methods.
64
65  * :meth:`whoosh.reading.IndexWriter.commit` -- Save the additions/deletions done with
66    this IndexWriter to the main index, and release any resources used by the IndexWriter.
67
68  * :meth:`whoosh.reading.IndexWriter.cancel` -- Throw away any additions/deletions done
69    with this IndexWriter, and release any resources used by the IndexWriter.
70
71
72IndexReader
73===========
74
75* Subclass :class:`whoosh.reading.IndexReader`.
76
77* IndexReaders must implement the following methods.
78
79  * :meth:`whoosh.reading.IndexReader.__contains__`
80
81  * :meth:`whoosh.reading.IndexReader.__iter__`
82
83  * :meth:`whoosh.reading.IndexReader.iter_from`
84
85  * :meth:`whoosh.reading.IndexReader.stored_fields`
86
87  * :meth:`whoosh.reading.IndexReader.doc_count_all`
88
89  * :meth:`whoosh.reading.IndexReader.doc_count`
90
91  * :meth:`whoosh.reading.IndexReader.doc_field_length`
92
93  * :meth:`whoosh.reading.IndexReader.field_length`
94
95  * :meth:`whoosh.reading.IndexReader.max_field_length`
96
97  * :meth:`whoosh.reading.IndexReader.postings`
98
99  * :meth:`whoosh.reading.IndexReader.has_vector`
100
101  * :meth:`whoosh.reading.IndexReader.vector`
102
103  * :meth:`whoosh.reading.IndexReader.doc_frequency`
104
105  * :meth:`whoosh.reading.IndexReader.frequency`
106
107* Backends that support deleting documents should implement the following
108  methods.
109
110  * :meth:`whoosh.reading.IndexReader.has_deletions`
111  * :meth:`whoosh.reading.IndexReader.is_deleted`
112
113* Backends that support versioning should implement the following methods.
114
115  * :meth:`whoosh.reading.IndexReader.generation`
116
117* If the IndexReader object does not keep the schema in the ``self.schema``
118  attribute, it needs to override the following methods.
119
120  * :meth:`whoosh.reading.IndexReader.field`
121
122  * :meth:`whoosh.reading.IndexReader.field_names`
123
124  * :meth:`whoosh.reading.IndexReader.scorable_names`
125
126  * :meth:`whoosh.reading.IndexReader.vector_names`
127
128* IndexReaders *may* implement the following methods.
129
130  * :meth:`whoosh.reading.DocReader.close` -- closes any open resources associated with the
131    reader.
132
133
134Matcher
135=======
136
137The :meth:`whoosh.reading.IndexReader.postings` method returns a
138:class:`whoosh.matching.Matcher` object. You will probably need to implement
139a custom Matcher class for reading from your posting lists.
140
141* Subclass :class:`whoosh.matching.Matcher`.
142
143* Implement the following methods at minimum.
144
145  * :meth:`whoosh.matching.Matcher.is_active`
146
147  * :meth:`whoosh.matching.Matcher.copy`
148
149  * :meth:`whoosh.matching.Matcher.id`
150
151  * :meth:`whoosh.matching.Matcher.next`
152
153  * :meth:`whoosh.matching.Matcher.value`
154
155  * :meth:`whoosh.matching.Matcher.value_as`
156
157  * :meth:`whoosh.matching.Matcher.score`
158
159* Depending on the implementation, you *may* implement the following methods
160  more efficiently.
161
162  * :meth:`whoosh.matching.Matcher.skip_to`
163
164  * :meth:`whoosh.matching.Matcher.weight`
165
166* If the implementation supports quality, you should implement the following
167  methods.
168
169  * :meth:`whoosh.matching.Matcher.supports_quality`
170
171  * :meth:`whoosh.matching.Matcher.quality`
172
173  * :meth:`whoosh.matching.Matcher.block_quality`
174
175  * :meth:`whoosh.matching.Matcher.skip_to_quality`
176