const Database = require('better-sqlite3'); const path = require('path'); const db = new Database(path.join(process.cwd(), 'rag-kb.db')); try { const docs = db.prepare('SELECT id, title, length(content_preview) as len, content_preview FROM documents WHERE content_preview IS NOT NULL AND content_preview != \'\' LIMIT 5').all(); console.log("Documents with content:", docs.map(d => ({ id: d.id, title: d.title, length: d.len, preview: d.content_preview.substring(0, 50) }))); const emptyDocs = db.prepare('SELECT id, title FROM documents WHERE content_preview IS NULL OR content_preview = \'\' LIMIT 5').all(); console.log("Documents without content:", emptyDocs); const totalDocs = db.prepare('SELECT count(*) as count FROM documents').get(); console.log("Total documents:", totalDocs); const totalEmpty = db.prepare('SELECT count(*) as count FROM documents WHERE content_preview IS NULL OR content_preview = \'\'').get(); console.log("Total empty documents:", totalEmpty); } catch (error) { console.error("Database error:", error); }