Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27152

Accept expressions (e.g. $range) for the 'boundaries' argument to $bucket.

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Query Optimization

      I am hoping I am simply missing something so obvious I am ignoring it.
      This works:

      c=db.cscl2.aggregate([
      {$bucket: {"groupBy": "$length",
                 boundaries: [0,5,10,15],
          default:"other" }}
                            ]);
      show(c);
      

      This does not:

                                                                   
      c=db.cscl2.aggregate([
      {$bucket: {"groupBy": "$length",
                 boundaries: {$range: [0,20,5 ]},
          default:"other" }}]);
      show(c);
       "errmsg" : "The $bucket 'boundaries' field must be an array, but found type: object.",
       "code" : 40200,                                                                        
       "codeName" : "Location40200"                                                           
      

      So changing [0,5,10,15] to {$range: [0,20,5]} creates the error.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            buzz.moschetti Buzz Moschetti
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: