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.
const client = mongoose.connection.getClient();
const vectorSearchIndexCommand = {
createSearchIndexes: collectionName, // Name of our collection
indexes: [
{
name: searchIndexName,
type: 'vectorSearch',
definition: {
fields: [
{
path: "embedding",
type: 'vector',
numDimensions: 1536,
similarity: 'cosine',
},
],
},
},
],
};
await client.db().command(vectorSearchIndexCommand);