I’m trying to create a vectorSearch index programmatically. I can create a search index with a knnVector, using createSearchIndex command but for a vector index defined like this:
fields: [{
path: ‘embedding’,
numDimensions: 1536,
similarity: ‘cosine’,
type: ‘vector’
}]
I couldn’t coerce the createSearchIndex command to create such an index. I’m developing a RAG AI application and need to create vectorSearch indexes on the fly. Is there a way to create this sort of index outside of the UI?
Sorry for the delay in response here. We are working on updating our docs to mention this as the change landed very recently, which should allow you to use the createSearchIndex command specifying type: vectorSearch , which is a sibling field to the index definition.
This is supported in the Atlas Admin API as well as mongosh 2.1.2 as well as the Atlas CLI 1.14.3, both running MongoDB v7.0.5.
Hey Henry!
Any chance to get a nodejs snippet for creating the index?
Tried it with the specified versions of mongosh and MongoDB but I could not make it work.
Hey! I use Mongoose and for some reason, the client I receive does not have the createSearchIndex function on it.
I managed to sort it out with the createSearchIndexes function.
I found out why, mongodb cli or its nodejs driver is restricted to the ‘expensive’ M10+ clusters. Why? I wish I knew.
Apparently you can create indexes even with an M0 cluster via interface or atlas api, but if you want to do in nodejs via mongodb driver, nope. Need to pay. I’d love to understading some reasoning behind this.