Aller au contenu principal

API Backends

Architecture de stockage pliable via backends.

FileBackend (défaut)​

class whoosh.backends.file.FileBackend

Backend par défaut stockant les segments comme fichiers sur disque.

Options​

ParamètreDescription
storageInstance de storage (FileStorage par défaut)
limitmbTaille maximum des segments (MiB)

Exemple:

from whoosh import index

ix = index.create_in("indexdir", schema)
# Utilise FileBackend implicitement

SQLiteBackend​

class whoosh.backends.sqlite.SQLiteBackend

Stocke l'index entier dans une base de données SQLite.

Options​

ParamètreDescription
storageSQLiteStorage(path)
writethroughÉcriture synchrone

Exemple:

from whoosh.backends.sqlite import SQLiteStorage, SQLiteBackend

storage = SQLiteStorage("mon_index.db")
backend = SQLiteBackend(storage=storage)

ix = backend.create_index(schema)

MemoryBackend​

class whoosh.backends.memory.MemoryBackend

Backend en mémoire (tests uniquement, données perdues au redémarrage).

Classes Storage​

FileStorage​

class whoosh.store.FileStorage

Gère les fichiers sur disque.

SQLiteStorage​

class whoosh.store.SQLiteStorage(db_path)

Gère le stockage SQLite.

ProviderRegistry​

class whoosh.registry.ProviderRegistry

Registre pour les providers de stockage:

from whoosh.registry import ProviderRegistry

ProviderRegistry.register("sqlite", SQLiteBackend(), "mon_app")