Vector Search: Unrecognized pipeline stage name: '$vectorSearch'

I get the following error when executing a vector search via Pymongo:

pymongo.errors.OperationFailure: Unrecognized pipeline stage name: ‘$vectorSearch’, full error: {‘ok’: 0.0, ‘errmsg’: “Unrecognized pipeline stage name: ‘$vectorSearch’”, ‘code’: 40324, ‘codeName’: ‘Location40324’,…

There is a similar thread here, but none of the responses resolve my issue. I have:

  1. Confirmed a successful connection to my cluster, database, and the appropriate collection (it is not a local instance)
  2. Confirmed the creation of my vector search index on the “embedding” field, pasted below:
{
  "fields": [
    {
      "numDimensions": 1,
      "path": "embedding",
      "similarity": "cosine",
      "type": "vector"
    }
  ]
}

And below is the query I am making. The embedding is a 1 dimensional array representing an image.

pipeline = [
    {
        "$vectorSearch": {
            "index": "vector_index",
            "path": "embedding",
            "queryVector": embedding.tolist(),
            "numCandidates": 5,
            "limit": 5,
        }
    }
]

results = collection.aggregate(pipeline)

Am I missing something here?

Hello @Lucas_Lind sorry you’re having an issue here, can you confirm this is a cluster in MongoDB Atlas? And what the version of the cluster is?

@Benjamin_Flast yes, I can confirm the cluster is in MongoDB atlas. The version is 5.0.23.

Hi @Lucas_Lind

You’ll need 6.011+, or 7.0.2+ for Vector Search:

https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/

You can perform semantic search on data in your Atlas cluster running MongoDB v6.0.11, v7.0.2, or later using Atlas Vector Search. You can store vector embeddings for any kind of data along with other data in your collection on the Atlas cluster. Atlas Vector Search supports embeddings that are less than and equal to 2048 dimensions in width.

2 Likes

@chris Thank you! This enabled me to perform the query without issue.

1 Like