C# aggregate, pagination lookup data structure changes with different pipeline loading approach


I am trying to do pagination with c# Mongodb driver. I have a collection called “Account”, from which I am doing lookup to “Contact”. I am having my pipeline stages. when I load the pipeline with appendstage one by one (like below)


it returns the value like this (which is Ok as I want it):

     ["data" : [ { "Account":{account_obj}, "Contact": {contact_obj} },
                     { "Account":{account_obj_2}, "Contact": {contact_obj_2} }],
      "count" : []

but when I load all pipelines at once like below:

The value returned turns out to be different like below:
      ["data" : [ { "Account":{account_obj}},
                     { "Account":{account_obj_2} }],
      "count" : [],
      "Contact": null

like you see the Contact lookup value is coming out of data.

Why is that ? What am I missing here? Any help would be much appreciated. Thanks.

Hi, I have fixed it. Sorry it was my mistake. I was loading the lookup to Contact after facet, now I loaded the lookup stage before facet stage into the pipeline, and it works as expected.

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