MongoEngine / mongoengine

A Python Object-Document-Mapper for working with MongoDB
http://mongoengine.org
MIT License
4.24k stars 1.23k forks source link

using vector search with mongoengine #2785

Open alexisdal opened 11 months ago

alexisdal commented 11 months ago

hello

I have been using mongoengine on my latest project and I'm happy with it.

somehow, I would like to push vectors (embeddings) into my mongodb collection and perform vector searches. It's apparently a fresh development of mongodb. source => https://www.mongodb.com/products/platform/atlas-vector-search

I made a simple lookup in the documentation and issues of mongoengine but did not find any matches.

what I want to achieve 1) push vectors in a collection 2) perform similarity search between a vector and the entire collection, retrieve the K-th closest matches (typically using cosine distance) 3) using the mongoengine abstraction layer

Any clue about how to do this ?

bagerard commented 10 months ago

There is no "specific" support built in MongoEngine but I'm not sure it's worth having one. There is an API for creating indexes in pymongo raw format, and an api for running aggregation pipeline also in raw format, have you tried to make use of these?

idoshr commented 10 months ago

From what I know about the vector search is part of the elastic search solution that Atlas provide. Maybe this library can be helpful https://github.com/certego/AtlasQ