fix(mongodb): cap numCandidates at 1000, raise on index failure, and add models_api dependency

This commit is contained in:
Young Han 2025-10-31 11:03:47 -07:00
parent ab824b53e3
commit 1b75792621

View file

@ -215,7 +215,7 @@ class MongoDBIndex(EmbeddingIndex):
"index": self.config.index_name, "index": self.config.index_name,
"queryVector": embedding.tolist(), "queryVector": embedding.tolist(),
"path": self.config.path_field, "path": self.config.path_field,
"numCandidates": k * 10, # Get more candidates for better results "numCandidates": min(k * 10, 1000), # Cap at 1000 to prevent excessive candidates
"limit": k, "limit": k,
} }
}, },