[DOCS-13770] [Server] $bucketAuto documentation states the max id is exclusive but it is inclusive for the last bucket Created: 17/Jul/20  Updated: 30/Oct/23  Resolved: 21/Jul/20

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: 3.6.17
Fix Version/s: Server_Docs_20231030

Type: Bug Priority: Major - P3
Reporter: Vincent Palodichuk Assignee: Jeffrey Allen
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

https://docs.mongodb.com/manual/reference/operator/aggregation/bucketAuto/


Participants:
Days since reply: 3 years, 28 weeks, 1 day ago
Story Points: 2

 Description   

Description

The documentation for $bucketAuto found here: https://docs.mongodb.com/manual/reference/operator/aggregation/bucketAuto/

 

States: "The document for each bucket contains an _id field, whose value specifies the inclusive lower bound and the exclusive upper bound for the bucket..."

 

The problem is that for the last bucket, the max value in the id field is inclusive.

 

The example on your page shows this to be the case:

 

Using these documents:

 

{ "_id" : 1, "title" : "The Pillars of Society", "artist" : "Grosz", "year" : 1926,     "price" : NumberDecimal("199.99"),     "dimensions" : \{ "height" : 39, "width" : 21, "units" : "in" }

}

{ "_id" : 2, "title" : "Melancholy III", "artist" : "Munch", "year" : 1902,     "price" : NumberDecimal("280.00"),     "dimensions" : \{ "height" : 49, "width" : 32, "units" : "in" }

}

{ "_id" : 3, "title" : "Dancer", "artist" : "Miro", "year" : 1925,     "price" : NumberDecimal("76.04"),     "dimensions" : \{ "height" : 25, "width" : 20, "units" : "in" }

}

{ "_id" : 4, "title" : "The Great Wave off Kanagawa", "artist" : "Hokusai",     "price" : NumberDecimal("167.30"),     "dimensions" : \{ "height" : 24, "width" : 36, "units" : "in" }

}

{ "_id" : 5, "title" : "The Persistence of Memory", "artist" : "Dali", "year" : 1931,     "price" : NumberDecimal("483.00"),     "dimensions" : \{ "height" : 20, "width" : 24, "units" : "in" }

}

{ "_id" : 6, "title" : "Composition VII", "artist" : "Kandinsky", "year" : 1913,     "price" : NumberDecimal("385.00"),     "dimensions" : \{ "height" : 30, "width" : 46, "units" : "in" }

}

{ "_id" : 7, "title" : "The Scream", "artist" : "Munch",     "price" : NumberDecimal("159.00"),     "dimensions" : \{ "height" : 24, "width" : 18, "units" : "in" }

}

{ "_id" : 8, "title" : "Blue Flower", "artist" : "O'Keefe", "year" : 1918,     "price" : NumberDecimal("118.42"),     "dimensions" : \{ "height" : 24, "width" : 20, "units" : "in" }

}

 

With this pipeline:

 

db.artwork.aggregate( [

   {

     $bucketAuto:

{          groupBy: "$price",          buckets: 4      }

   }

] )

 

Produces these four buckets:

 

{

  "_id" :

{     "min" : NumberDecimal("76.04"),     "max" : NumberDecimal("159.00")   }

,

  "count" : 2

}

{

  "_id" :

{     "min" : NumberDecimal("159.00"),     "max" : NumberDecimal("199.99")   }

,

  "count" : 2

}

{

  "_id" :

{     "min" : NumberDecimal("199.99"),     "max" : NumberDecimal("385.00")   }

,

  "count" : 2

}

{

  "_id" :

{     "min" : NumberDecimal("385.00"),     "max" : NumberDecimal("483.00")   }

,

  "count" : 2

}

 

Notice how the max of the last bucket matches the highest price document.

 

We ask that the documentation be updated to confirm that this is the correct behavior as right now it appears to be a bug since the documentation states the max id is suppose to be exclusive.

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Vincent Palodichuk [ 28/Jul/20 ]

Thanks for the quick turn-a-round on this!!

Comment by Githook User [ 21/Jul/20 ]

Author:

{'name': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com', 'username': 'jeff-allen-mongo'}

Message: (DOCS-13770): Clarifications to bucketAuto
Branch: v3.6
https://github.com/mongodb/docs/commit/d2c7150ea3c0437b4b5c0d7af3d192fda710cbaa

Comment by Githook User [ 21/Jul/20 ]

Author:

{'name': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com', 'username': 'jeff-allen-mongo'}

Message: (DOCS-13770): Clarifications to bucketAuto
Branch: v4.0
https://github.com/mongodb/docs/commit/507e31281276f4ed2e833e06e920d018607aa23a

Comment by Githook User [ 21/Jul/20 ]

Author:

{'name': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com', 'username': 'jeff-allen-mongo'}

Message: (DOCS-13770): Clarifications to bucketAuto
Branch: v4.2
https://github.com/mongodb/docs/commit/b8a7bea230a71c40aae86a324431ba01c980d359

Comment by Githook User [ 21/Jul/20 ]

Author:

{'name': 'jeff-allen-mongo', 'email': 'jeffrey.allen@10gen.com', 'username': 'jeff-allen-mongo'}

Message: (DOCS-13770): Clarifications to bucketAuto
Branch: master
https://github.com/mongodb/docs/commit/da99c41dc308f93c7cb445b246a69d2fbd93eb32

Comment by Vincent Palodichuk [ 17/Jul/20 ]

I selected the wrong version. We are using MongoDB 4.2

Generated at Thu Feb 08 08:08:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.