async def get_index(db, index_id_or_version, projection=None):
    """
    Get an index document by its ``id`` or ``version``.

    :param db: the application database client
    :type db: :class:`~motor.motor_asyncio.AsyncIOMotorClient`

    :param index_id_or_version: the id of the index
    :type index_id_or_version: Union[str, int]

    :param projection: a Mongo projection to apply to the result
    :type projection: Union[None, dict, list]

    :return: an index document
    :rtype: Union[None, dict]

    """
    try:
        return await db.indexes.find_one({"version": int(index_id_or_version)}, projection=projection)
    except ValueError:
        return await db.indexes.find_one(index_id_or_version, projection=projection)