Skip to content

Commit 016346c

Browse files
committed
connection error - fix score
1 parent 43c5c7a commit 016346c

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/core/IndexManager.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,46 +45,39 @@ class IndexManager {
4545

4646
buildSearchQuery(embedding, filter = {}, options = {}) {
4747
const vectorSearchQuery = {
48-
index: this.indexName, // Now correctly assigned
49-
path: this.embeddingFieldPath, // Now correctly assigned
48+
index: this.indexName,
49+
path: this.embeddingFieldPath,
5050
queryVector: embedding,
5151
limit: options.maxResults || 10,
5252
exact: options.exact || false
5353
};
54-
54+
5555
if (!vectorSearchQuery.exact) {
5656
vectorSearchQuery.numCandidates = options.numCandidates || 100;
5757
}
58-
58+
5959
const pipeline = [
6060
{
6161
$vectorSearch: vectorSearchQuery
6262
},
6363
{
64-
$addFields: {
65-
score: { $meta: "searchScore" }
66-
}
67-
}
68-
];
69-
70-
if (Object.keys(filter).length > 0) {
71-
pipeline[0].$vectorSearch.filter = filter;
72-
}
73-
74-
if (options.includeMetadata) {
75-
pipeline.push({
7664
$project: {
7765
documentId: 1,
7866
content: 1,
7967
metadata: 1,
80-
score: 1
68+
score: { $meta: "vectorSearchScore" } // Ensure score is always included
8169
}
82-
});
70+
}
71+
];
72+
73+
if (Object.keys(filter).length > 0) {
74+
pipeline[0].$vectorSearch.filter = filter;
8375
}
84-
76+
8577
console.log('Generated search query:', JSON.stringify(pipeline, null, 2));
8678
return pipeline;
8779
}
80+
8881

8982

9083
async getIndexStats() {

0 commit comments

Comments
 (0)