No results returned from agglomerate(pipeline) call on collection

As something new to me I am trying Agglomeration Pipelines in Python. The following code runs without error. The database and the collection are valid, I am able to itterate and list the databases and collections in the client. The pipeline is valid, I have tested in mongodb compass, with the same connection string, by copying and pasting the pipeline. However the agglomerate(pipeline) does not return the expected document. <pymongo.synchronous.command_cursor.CommandCursor object at 0x000002421B146B70> is returned.
My connection string is “mongodb+srv://username:password@langchaintestcluster.lnd7p.mongodb.net/?retryWrites=true&w=majority&appName=LongChainTest”

If I create the same project locally and connect using “mongodb://localhost:27017/” then I get the expected result i.e. the document is returned.
Appreciate any help, I have followed the available documentation and samples but with no resolution.

from pymongo import MongoClient
import pymongo
from config import ConfigData

client = pymongo.MongoClient(ConfigData.MONGO_DB_URI)

db = client[ConfigData.DB_NAME]
collection_name = db[ConfigData.COLLECTION_NAME]

pipeline = [{‘$match’: {‘name’: ‘Glenn’}}]

result = collection_name.aggregate(pipeline)

count = 0
for doc in result:
count +=1
print(doc)

print(count)
#Allways prints 0

Hi Glen,

Apologies if this is obvious, but are you sure whatever you have set in ConfigData as your database and collection names is correct and consistent with the names used in Atlas i.e no minor typos? If you try to run an aggregation against a collection or database that doesn’t exist, MongoDB will just return an empty result set.

I happened to notice in your connection string you have appName set to “LongChainTest” (with an ‘o’). Should this be “LangChainTest” (with an ‘a’)? Is there perhaps something similar in either your database name or collection name?