[SERVER-58968] Add "exclusive" boolean flag to the _id field of the bucket document generated using $bucketAuto Created: 17/Jul/20  Updated: 16/Sep/21  Resolved: 16/Sep/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.2.8
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Vincent Palodichuk Assignee: Edwin Zhou
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Right now the $bucketAuto aggregation operator produces a document whose _id field contains the inclusive min and (sometimes) exclusive max values of the bucket.

I noted that the max is sometimes exclusive as it is inclusive for the the last bucket that is generated.

If we have thousands of buckets, in order to determine which one is inclusive, we have to sort the buckets by their _id and that can take time. To avoid having to do the sort, we are asking that a flag of some kind be included to indicate if the max value is inclusive or exclusive.

Thank you.



 Comments   
Comment by Edwin Zhou [ 16/Sep/21 ]

Hi vincent.palodichuk@primetherapeutics.com,

We haven’t heard back from you for some time, so I’m going to close this ticket. If this is still an issue for you, please provide additional information and we will reopen the ticket.

Best,
Edwin

Comment by Edwin Zhou [ 03/Sep/21 ]

Hi vincent.palodichuk@primetherapeutics.com,

We still need additional information to diagnose the problem. If this is still an issue for you, would you please clarify if the above example represents the improvement you're looking for?

Best,
Edwin

Comment by Edwin Zhou [ 12/Aug/21 ]

Hi vincent.palodichuk@primetherapeutics.com,

Thanks for your improvement request. I'd like to clarify the specific improvement you're interested in. Taking an example from our $bucketAuto docs, each bucket from $bucketAuto currently looks like this:

{
  "_id" : {
    "min" : NumberDecimal("76.04"),
    "max" : NumberDecimal("159.00")
  },
  "count" : 2
}
...
{
  "_id" : {
    "min" : NumberDecimal("385.00"),
    "max" : NumberDecimal("483.00")
  },
  "count" : 2
}

This is an example I came up with based on your improvement description:

{
  "_id" : {
    "min" : NumberDecimal("76.04"),
    "max" : NumberDecimal("159.00")
  },
  "count" : 2,
  "exclusive" : true
}
...
{
  "_id" : {
    "min" : NumberDecimal("385.00"),
    "max" : NumberDecimal("483.00")
  },
  "count" : 2
  "exclusive" : false
}

Are you specifically interested in seeing the output improved with an explicit exclusive field in each document?

Best,
Edwin

Comment by Vincent Palodichuk [ 17/Jul/20 ]

I selected the wrong version. We are using MongoDB 4.2

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