I have the same problem however my code worked a few weeks ago. I also use MongoDBAtlasVectorSearch from LangChain. I did some research and found out that even direct querying from Atlas UI page using $vectorSearch doesn’t work anymore.
My search index looks like this
{
"mappings": {
"dynamic": false,
"fields": {
"embedding": {
"dimensions": 1536,
"similarity": "cosine",
"type": "knnVector"
},
"location": {
"type": "geo"
}
}
}
}
There is also a geo-index part here but it doesn’t matter. Here is the search query:
{
"$vectorSearch": {
"index": "vector_geo_index",
"path": "embedding",
"numCandidates": 10,
"limit": 2,
"queryVector": [...]
}
}
Error: Failed to run this query. Reason: $vectorSearch is not allowed or the syntax is incorrect, see the Atlas documentation for more information
This did work previously. Also, the old (deprecated in favor of $vectorSearch) knnBeta operator works fine:
{
"$search": {
"index": "vector_geo_index",
"knnBeta": {
"vector": [...],
"path": "embedding",
"k": 2
}
}
}
My guess it is not related to Langchain. It is probably something on the Atlas side. Docs say that the vector search is a preview feature and not recommended for prod. Maybe it is not very stable at the moment.