Performing vector searches with $vectorSearch
Now that you’ve created your vector embeddings and successfully indexed them, it’s time to unleash the true power of Atlas Vector Search! Are you ready to see how we can query data based on semantic meaning rather than exact text matches?
In this section, we’ll walk through performing vector searches using the $vectorSearch
aggregation stage. This powerful feature allows you to find documents based on the semantic similarity between your query and the vector embeddings in your database.
Let’s look at a complete example of how to perform a vector search:
import key_param
from pymongo import MongoClient
import voyageai
vo = voyageai.Client(api_key=key_param.voyage_api_key)
mongodb_client = MongoClient(key_param.mdb_uri)
# Database name
DB_NAME = "sample_mflix"
# Name of the collection with full documents- used for summarization
FULL_COLLECTION_NAME = "movies"
db = mongodb_client...