Aggregation group pipeline issue

We are having two environments (local1and local2), both environment we are using Mongodb for storing and retrieving data. We have an availability to use aggression with multiple pipelines in both region but the both resultset provides different values.

Data available in the both the region are same and aggression query we used to fetch the data is same, but we got the different values.

While we inspect the individual pipeline, we are getting a different resultset from the group pipeline. Could you please help on this issue?

In principal the same queries over the same data provides the same result.

Except for 2 cases.

  1. You do not sort, so the result might be the same but not in the same order.
  2. You do sort, but you have some duplicate values. The order of the duplicate values might differ.

Note that if you do not sort or sort and have duplicates, your $limit:n will not provide the same documents.

If you do not sort or sort and have duplicates, things like $first for your $group will not provide the same documents.

1 Like

Please double check that your data is really the same in the two cases.