File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -333,6 +333,11 @@ export async function sqlite(config: SqliteConfig): Promise<SearchProvider> {
333333 }
334334 } ,
335335
336+ async listIds ( ) {
337+ const rows = db . prepare ( 'SELECT id FROM documents_meta' ) . all ( ) as Array < { id : string } >
338+ return rows . map ( r => r . id )
339+ } ,
340+
336341 async clear ( ) {
337342 db . exec ( 'DELETE FROM documents_fts' )
338343 db . exec ( 'DELETE FROM documents_vec' )
Original file line number Diff line number Diff line change @@ -226,6 +226,19 @@ export async function createRetriv(options: RetrivOptions): Promise<SearchProvid
226226 return { count : results [ 0 ] ?. count ?? 0 }
227227 } ,
228228
229+ async listIds ( ) {
230+ const driver = drivers . find ( d => d . listIds )
231+ const ids = await driver ?. listIds ?.( ) ?? [ ]
232+ if ( ! chunker )
233+ return ids
234+ const parentIds = new Set < string > ( )
235+ for ( const id of ids ) {
236+ const sep = id . indexOf ( '#chunk-' )
237+ parentIds . add ( sep >= 0 ? id . substring ( 0 , sep ) : id )
238+ }
239+ return Array . from ( parentIds )
240+ } ,
241+
229242 async clear ( ) {
230243 await Promise . all ( drivers . filter ( d => d . clear ) . map ( d => d . clear ! ( ) ) )
231244 parentDocs . clear ( )
Original file line number Diff line number Diff line change @@ -137,6 +137,11 @@ export interface SearchProvider {
137137 */
138138 remove ?: ( ids : string [ ] ) => Promise < { count : number } >
139139
140+ /**
141+ * List all indexed document IDs
142+ */
143+ listIds ?: ( ) => Promise < string [ ] >
144+
140145 /**
141146 * Clear all indexed documents
142147 */
You can’t perform that action at this time.
0 commit comments