$vectorSearch inside $unionWith


I am looking for a way to merge $vectorSearch results from multiple collections, and found that $vectorSearch is disallowed inside $unionWith, while the $search is allowed. So I want to know more about the reason. I think $vectorSearch and $search are based on a similar mechanism when comminicating between mongod and mongot ?


Hi @mingtotti_N_A! Thank you for submitting your question.

You are right that these stages are based on similar communication mechanisms when passing data across processes. We released $vectorSearch with some usage limitations initially to limit the blast radius of supporting a new aggregation stage, but are working on expanding functionality such as supporting it within $unionWith for multiple vector search and having more supported prefilter types now that it’s been out for a while.

I hope that answers your question!

@Henry_Weller , Thanks for your answer, and looking forward to the expanding functionality for $vectorSearch.