migrate_pgvector_to_sqlite

View as MarkdownOpen in Claude

Create a SQLite .swsearch file from a pgvector collection’s schema and configuration.

This method currently creates the SQLite schema and copies configuration only — chunk data is not transferred. Full chunk migration from pgvector to SQLite is planned for a future release. The returned chunks_migrated count will be 0.

Parameters

connection_string
strRequired

PostgreSQL connection string.

collection_name
strRequired

Name of the source pgvector collection.

output_path
strRequired

Output path for the .swsearch file. The .swsearch extension is appended automatically if not present.

batch_size
intDefaults to 100

Number of chunks to fetch per batch.

Returns

dict[str, Any] — Migration statistics with source, target, chunks_migrated, errors, and config fields.

Example

1from signalwire.search import SearchIndexMigrator
2
3migrator = SearchIndexMigrator(verbose=True)
4stats = migrator.migrate_pgvector_to_sqlite(
5 connection_string="postgresql://user:pass@localhost/mydb",
6 collection_name="knowledge",
7 output_path="./knowledge-backup.swsearch",
8)
9
10print(f"Migrated {stats['chunks_migrated']} chunks to {stats['target']}")