All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m12s
Replace JSON-string embeddings with native pgvector(1536) storage and add PostgreSQL full-text search (tsvector/GIN) with Reciprocal Rank Fusion for hybrid keyword + semantic ranking. Changes: - NoteEmbedding.embedding: String → vector(1536) via pgvector - NoteEmbedding: added updatedAt for reindex tracking - Note: added tsv (tsvector) with auto-update trigger for FTS - semantic-search.service: hybrid FTS + vector search with RRF fusion - embedding.service: toVectorString() for pgvector SQL literals - Removed JS-side cosine similarity loops (now DB-side via <=>) - Added HNSW index on NoteEmbedding.embedding (cosine distance) - Added GIN index on Note.tsv for FTS queries Schema migration in: prisma/migrations/20260512120000_pgvector_and_fts_search/ Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
|
|
import { prisma } from '../lib/prisma'
|
|
|
|
function parseNote(dbNote: any) {
|
|
return {
|
|
...dbNote,
|
|
checkItems: dbNote.checkItems ? JSON.parse(dbNote.checkItems) : null,
|
|
labels: dbNote.labels ? JSON.parse(dbNote.labels) : null,
|
|
images: dbNote.images ? JSON.parse(dbNote.images) : null,
|
|
links: dbNote.links ? JSON.parse(dbNote.links) : null,
|
|
sharedWith: dbNote.sharedWith ? JSON.parse(dbNote.sharedWith) : [],
|
|
size: dbNote.size || 'small',
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
console.log('Testing parseNote logic...')
|
|
|
|
const rawNote = await prisma.note.findFirst({
|
|
where: { size: 'large' }
|
|
})
|
|
|
|
if (!rawNote) {
|
|
console.error('No large note found in DB.')
|
|
return
|
|
}
|
|
|
|
console.log('Raw Note from DB:', { id: rawNote.id, size: rawNote.size })
|
|
|
|
const parsed = parseNote(rawNote)
|
|
console.log('Parsed Note:', { id: parsed.id, size: parsed.size })
|
|
|
|
if (parsed.size === 'large') {
|
|
console.log('parseNote preserves size correctly.')
|
|
} else {
|
|
console.error('parseNote returned wrong size:', parsed.size)
|
|
}
|
|
}
|
|
|
|
main().catch(console.error).finally(() => prisma.$disconnect())
|