@@ -112,24 +112,24 @@ func (ms *MongoStore) SearchMemory(ctx context.Context, sessionID string, queryE
112112 // Use $vectorSearch for efficient similarity search in MongoDB Atlas.
113113 pipeline := mongo.Pipeline {
114114 {
115- {"$vectorSearch" , bson.D {
116- {"index" , "vector_index" },
117- {"path" , "embedding" },
118- {"queryVector" , float64Embedding (queryEmbedding )},
119- {"numCandidates" , int64 (limit * 10 )}, // Oversample for better accuracy
120- {"limit" , int64 (limit )},
115+ {Key : "$vectorSearch" , Value : bson.D {
116+ {Key : "index" , Value : "vector_index" },
117+ {Key : "path" , Value : "embedding" },
118+ {Key : "queryVector" , Value : float64Embedding (queryEmbedding )},
119+ {Key : "numCandidates" , Value : int64 (limit * 10 )}, // Oversample for better accuracy
120+ {Key : "limit" , Value : int64 (limit )},
121121 }},
122122 },
123123 {
124- {"$addFields" , bson.D {
125- {"score" , bson.D {{"$meta" , "vectorSearchScore" }}},
124+ {Key : "$addFields" , Value : bson.D {
125+ {Key : "score" , Value : bson.D {{Key : "$meta" , Value : "vectorSearchScore" }}},
126126 }},
127127 },
128128 }
129129
130130 // Add a $match stage if sessionID is provided.
131131 if sessionID != "" {
132- pipeline = append (pipeline , bson.D {{"$match" , bson.D {{"session_id" , sessionID }}}})
132+ pipeline = append (pipeline , bson.D {{Key : "$match" , Value : bson.D {{Key : "session_id" , Value : sessionID }}}})
133133 }
134134
135135 cursor , err := ms .collection .Aggregate (ctx , pipeline )
@@ -223,14 +223,14 @@ func (ms *MongoStore) CreateSchema(ctx context.Context, _ string) error {
223223 // Vector search index for Atlas
224224 {
225225 Keys : bson.D {
226- {"embedding" , "cosmos.vector" },
226+ {Key : "embedding" , Value : "cosmos.vector" },
227227 },
228228 Options : options .Index ().
229229 SetName ("vector_index" ).
230230 SetWeights (bson.D {
231- {"numDimensions" , 768 }, // Assuming 768, adjust as needed
232- {"similarity" , "cosine" },
233- {"type" , "ivf" },
231+ {Key : "numDimensions" , Value : 768 }, // Assuming 768, adjust as needed
232+ {Key : "similarity" , Value : "cosine" },
233+ {Key : "type" , Value : "ivf" },
234234 }),
235235 },
236236 }
0 commit comments