Possible to create search index on free tier w/pymongo?

I’m doing some testing with the Mongo Atlas free tier. The free tier appears to only support version 6. The pymongo docs suggest that Atlas 7.0+ is required to call collection.create_search_index. However, since I am able to create the search index on the web console using the JSON editor, I just wanted to confirm if this is still the case.

I’ve tried the following:

search_index_model = operations.SearchIndexModel(
    definition={
        "mappings": {
            "dynamic": True,
            "fields": {
                "values": {
                    "type": "knnVector",
                    "dimensions": 768,
                    "similarity": "cosine",
                }
            },
        },
    },
    name="embeddings2",
)

collection.create_search_index(model=search_index_model)

But it fails with OperationFailure: command not found.

Hi @Matthew_Twomey - Welcome to the community.

As per the 7.0 release notes (specific to Atlas Search index management):

Starting in MongoDB 7.0, you can manage Atlas Search indexes with mongosh methods and database commands. Atlas Search index commands are only available for deployments hosted on MongoDB Atlas, and require an Atlas cluster tier of at least M10

I don’t know the exact reason but my best guess is that the create search index database command was more recently introduced (in 7.0) and M0 tier clusters are currently on 6.0.11.

You can continue creating the search index from the UI for the free tier at this stage.

Hope this answers your question / clears things up.

Regards,
Jason

That does help, thank you for confirming.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.