Can't create search index on view through node js driver

I’m trying to create a search index on a view. I followed the steps on this page: Use MongoDB Views to Transform Documents and Filter Collections for Atlas Vector Search - Atlas - MongoDB Docs

However, i’m only able to create the search index using the UI. When i try to create using the nodejs mongodb driver or the mongo shell, i get the error: Collection <collection_name> does not exist.

On node i’m trying to do:

db.collection('view_name').createSearchIndex({
      name: indexName,
      type: "search", definition : {.....}})

On mongodb shell I’m trying to do:

db.collection.createSearchIndex("index_name", {.....})

Both of these options lead to the same error. Is it currently only possible through UI for views?

Found this in same document now.

Atlas UI and the Atlas Administration API to create Atlas Vector Search indexes on Views. Support for mongosh, Compass, and Drivers will be available when this feature is Generally Available.

Did you replace “collection” with the name of the collection in your database that you want to create the index for? If no, that’s most likely what’s causing the error, as MongoDB can’t find any collection named “collection” in your database.