Text stores¶
InMemoryTextSearchStore(facet_keys=...)suits tests and short-lived runs. It matches exactly the records the SQLite store matches and scores with the same BM25 formula.AsyncSqliteFts5Store(path, facet_keys=..., weights=...)persists the index. Each article's text is stored once, each write is one transaction, and every SQLite failure, including a file that isn't a database, raisesSearchStoreError.weights=BM25Weights(title=10.0, abstract=4.0, body=1.0)sets how much a match in each field counts; those are the defaults.- Memory settings are opt-in.
tuning=SqliteTuning(cache_size=200 * 2**20, mmap_size=2 * 2**30)gives the store's connection a page cache and a memory map of those sizes, in bytes. They speed up queries once the index outgrows SQLite's default cache of about 2 MB, at the cost of memory. Withouttuning, SQLite's defaults apply. - FTS5 is required. The store needs a Python whose SQLite was built with
FTS5, and raises
SearchStoreErrorwhen it is constructed otherwise.fts5_available()checks in advance;InMemoryTextSearchStoreworks everywhere. - Maintenance is explicit.
optimize()merges the index's segments.integrity_check()returnsFalsewhen the index disagrees with the stored documents, for example after the file was edited by other tools, andrebuild_index()repairs it from the stored text without fetching anything. A file created by a newer version of the library raisesSearchStoreErrorrather than being used. - Custom stores subclass
AsyncTextSearchStore; see Adding a new component.