Database instance (supports node:sqlite, better-sqlite3, @photostructure/sqlite)
Name for the virtual table
Index configuration
// Basic index
createDiskAnnIndex(db, "clip_embeddings", {
dimension: 512,
metric: "cosine",
maxDegree: 64
});
// With metadata columns for filtered search
createDiskAnnIndex(db, "photos", {
dimension: 512,
metric: "cosine",
metadataColumns: [
{ name: 'category', type: 'TEXT' },
{ name: 'year', type: 'INTEGER' }
]
});
Helper to create DiskANN virtual table with proper SQL escaping