Skip to content

Commit 0cc915f

Browse files
committed
fix search
1 parent 5ef606c commit 0cc915f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bin/commands/data/search.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@ export async function searchDocuments(config, query, options = {}) {
2323

2424
await rag.connect();
2525

26+
const indexName = config.indexName || 'vector_index';
27+
28+
const existingIndexes = await rag.collection.listIndexes().toArray();
29+
const hasIndex = existingIndexes.some(index => index.name === indexName);
30+
31+
if (!hasIndex) {
32+
throw new Error(`Index '${indexName}' does not exist. Please ensure the index is created.`);
33+
}
34+
2635
const searchOptions = {
2736
database: options.database || config.database,
2837
collection: options.collection || config.collection,
2938
maxResults: options.maxResults || config.search?.maxResults || 5,
3039
minScore: options.minScore || config.search?.minScore || 0.7,
31-
includeMetadata: true
40+
includeMetadata: true,
41+
indexName
3242
};
3343

3444
if (isDevelopment) {

0 commit comments

Comments
 (0)