馃憪 Perform semantic search
Now let's run some vector search queries against our data present in MongoDB.
Fill in any <CODE_BLOCK_N>
placeholders and run the cells under the Step 8: Perform semantic search on your data section in the notebook to run vector search queries against your data.
The answers for code blocks in this section are as follows:
CODE_BLOCK_9
Answer
get_embedding(user_query)
CODE_BLOCK_10
Answer
[
{
"$vectorSearch": {
"index": ATLAS_VECTOR_SEARCH_INDEX_NAME,
"queryVector": query_embedding,
"path": "embedding",
"numCandidates": 150,
"limit": 5
}
},
{
"$project": {
"_id": 0,
"body": 1,
"score": {"$meta": "vectorSearchScore"}
}
}
]
CODE_BLOCK_11
Answer
collection.aggregate(pipeline)