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