Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-4364

Compass pipeline export to Java not producing same results

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: None
    • Component/s: Export to Language
    • None
    • Environment:
      Spring boot 2.3.1, MongoDB 4.2.8 Community ,Win 10
    • Iteration Jackfruit, Iteration Lime, Iteration Maracuja, Iteration Nectarine
    • Not Needed

      Mongo Pipeline

      [\{$match: {[
       {$match: {  pd: 'PD',  type: 'type1',  date: {    $gte: '2019-01-01',    $lte: '2019-12-01'  }}}, 
       {$sort: {  pd: 1,  date: 1}}, 
       {$group: {  
            _id: {    site: '$site'  },  
             wf: {    $push: {      date: '$date',      resources: '$resources'}} {{        }  }, 
             resources: \{    $sum: '$resources'  }}}, \{$match: {  resources: {    $gt: 0  }}
        }
      ]
      
      Arrays.asList(
          match(and(eq("pd", "PD"), eq("type", "type1"), and(gte("date", "2019-01-01"), lte("date", "2019-12-01")))), 
          sort(orderBy(ascending("pd"), ascending("date"))), 
          group(
                eq("site", "$site"),
                push("wf", and(eq("date", "$date"), eq("resources", "$resources"))), 
                sum("resources", "$resources")), match(gt("resources", 0L)));
      

      Output from Mongo Query is in the attached file view.json

      Output from Java aggregates framework is 

      Document\{{_id=Document{{site=T}}, wf=[true, true, true, true, true, true, true, true, true, true, true, true], tresources=21.0}}}}
      {{2020-07-08 14:19:53.095 INFO 24544 --- [ main] com.example.services.PcfReportsService : Document\{{_id=Document{{site=G}}, wf=[true, true, true, true, true, true, true, true, true, true, true, true], tresources=458.0}}}}
      

       
      The problem is that the collected items in the group are returned as True and False which is not correct and also not what is produced when using this pipeline in shell . I have no other option but to post it here as a bug . Currently I am using @aggregates to do this operation. Also It would be nice to pass the pipeline array as a single string in aggregation parameter. Currently I break the pipeline above  and add it as @aggregation(pipeline={p1,p2,p3...pn}).

        1. view.json
          2 kB
        2. wfsample.json
          4 kB

            Assignee:
            anna.herlihy@mongodb.com Anna Herlihy (Inactive)
            Reporter:
            abledear@gmail.com Sam Sam
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: