Atlas Vector Search + Geospatial, PLEASE!

Hey MongoDB,

Seems like it’s impossible to use Atlas Vector Search together with any kind of geospatial filtering like $geoWithin. (Except for the now deprecated KnnBeta in Atlas Search) :frowning:

I would love if you could make it possible to use vector search together with a geospatial query!

I know this isn’t much of an answer, but I did see a partial answer to a similar question here.

Hey Dave, yea me too, thanks though. KnnBeta is deprecated now and I remember at one point running into some limitations using the Atlas Search filters vs just using a $match stage when you need to do some complex stuff, so I didn’t bother trying to make it work for now.

2 Likes

Hi @Julius_L ,

I worked on a workaround for that limitations using first a process that does a $merge of a geo query into a vector index temp (staging) collection and then running a similarity search.

You can see how it works in this hugging face space :

The code is here :

Thanks
Pavel

3 Likes

So glad to see more requests for this! This is something I have been requesting for a while, and though it’s not yet supported, there are ways you can implement the same (ish) solution using comparison query operators on your location field (or whatever you are using to store your lat/lng).

If you’re trying to emulate $geoWithin, you can instead create a bounding box by calculating the min/max latitude and longitude values, respectively (4 total values). Then, you can add a $filter field within your vector search to only accept latitude and longitude values that fall within these ranges.

I implemented this solution just a few days ago, and it has made a significant impact on our vector search performance. Hope this helps!

1 Like

Thanks for the tips @Pavel_Duchovny and @Lucas_Lind!
Seems like it might still be a bit too early for me to want to mess around with.

What do you guys do for pagination together with Vector Search? Seems like that’s not possible either?