* Match-everything path used when the user supplied only field * filters (`kind:function lang:typescript`) with no text. Returns * candidates ordered by name; the caller's filter pass narrows to * what was asked for.
(options: {
kinds?: NodeKind[];
languages?: Language[];
limit: number;
})
| 1286 | * what was asked for. |
| 1287 | */ |
| 1288 | private searchAllByFilters(options: { |
| 1289 | kinds?: NodeKind[]; |
| 1290 | languages?: Language[]; |
| 1291 | limit: number; |
| 1292 | }): SearchResult[] { |
| 1293 | const { kinds, languages, limit } = options; |
| 1294 | let sql = 'SELECT * FROM nodes WHERE 1=1'; |
| 1295 | const params: (string | number)[] = []; |
| 1296 | if (kinds && kinds.length > 0) { |
| 1297 | sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`; |
| 1298 | params.push(...kinds); |
| 1299 | } |
| 1300 | if (languages && languages.length > 0) { |
| 1301 | sql += ` AND language IN (${languages.map(() => '?').join(',')})`; |
| 1302 | params.push(...languages); |
| 1303 | } |
| 1304 | sql += ' ORDER BY name LIMIT ?'; |
| 1305 | params.push(limit); |
| 1306 | const rows = this.db.prepare(sql).all(...params) as NodeRow[]; |
| 1307 | return rows.map((row) => ({ node: rowToNode(row), score: 1 })); |
| 1308 | } |
| 1309 | |
| 1310 | /** |
| 1311 | * Fuzzy fallback: when zero FTS/LIKE hits, try an edit-distance |
no test coverage detected