cannot list search indexes with PyMongo list_search_indexes on M0 Atlas

It seems there is some limitation in how I can access search index functionality on the latest Atlas version (7.0.8) with latest Pymongo (4.6.3) and Motor (3.4.0). Sample code below and output follows. Looking at the docs, this should have worked. Note that this is on a free tier Atlas database. I can see and use the search index in all my other code, but listing and creating programmatically don’t work (I have to resort to the UI).

import os

from motor.motor_asyncio import AsyncIOMotorClient


async def hack():
    db = AsyncIOMotorClient(os.getenv('MONGODB_NAME')).get_default_database()

    print((await db.command({'buildInfo':1}))['version'])

    async for index in db['chats'].list_indexes():
        print(index)

    async for index in db['chats'].list_search_indexes():
        print(index)

if __name__ == "__main__":
    import asyncio
    asyncio.run(hack())

Outputs the following, then raises an exception on the list_search_index call:

7.0.8
SON([('v', 2), ('key', SON([('_id', 1)])), ('name', '_id_')])
raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: $listSearchIndexes is not allowed or the syntax is incorrect, see the Atlas documentation for more information, full error: {'ok': 0, 'errmsg': '$listSearchIndexes is not allowed or the syntax is incorrect, see the Atlas documentation for more information', 'code': 8000, 'codeName': 'AtlasError'}

Great insight. Our M0 Atlas clusters currently do not support driver-level operations to create, retrieve, edit, or delete atlas search indexes.

We do, however, plan on making these functionalities available in the future for M0.

Hope this helps!

1 Like