Skip to content

Commit 9ab9fc1

Browse files
committed
fix indexname
1 parent a044265 commit 9ab9fc1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/core/IndexManager.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ const log = debug('mongodb-rag:index');
55
class IndexManager {
66
constructor(collection, options = {}) {
77
this.collection = collection;
8+
this.indexName = options.indexName || 'vector_index'; // <-- Fix: Assign indexName
9+
this.embeddingFieldPath = options.embeddingFieldPath || 'embedding'; // <-- Fix: Assign embeddingFieldPath
810
this.options = {
9-
indexName: options.indexName || 'default',
1011
dimensions: options.dimensions || 1536,
1112
similarity: options.similarity || 'cosine',
1213
...options
1314
};
1415
}
15-
1616
async ensureIndexes() {
1717
try {
1818
log("Checking indexes...");
@@ -45,8 +45,8 @@ class IndexManager {
4545

4646
buildSearchQuery(embedding, filter = {}, options = {}) {
4747
const vectorSearchQuery = {
48-
index: this.indexName, // <-- Use configured index name
49-
path: this.embeddingFieldPath, // <-- Use configured embedding field path
48+
index: this.indexName, // Now correctly assigned
49+
path: this.embeddingFieldPath, // Now correctly assigned
5050
queryVector: embedding,
5151
limit: options.maxResults || 10,
5252
exact: options.exact || false

src/core/MongoRAG.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ class MongoRAG {
136136
const { database, collection, maxResults = 5 } = options;
137137
const col = await this._getCollection(database, collection);
138138
const embedding = await this._getEmbedding(query);
139+
console.log('[DEBUG] Using vector search index:', this.config.indexName);
139140

140141
const indexManager = new IndexManager(col, {
141-
indexName: this.config.indexName, // <-- Pass configured index name
142-
embeddingFieldPath: this.config.embeddingFieldPath, // <-- Pass embedding field path
142+
indexName: this.config.indexName,
143+
embeddingFieldPath: this.config.embeddingFieldPath,
143144
dimensions: this.config.embedding.dimensions
144145
});
145146

0 commit comments

Comments
 (0)