Facets: Auto Buckets Handouts bug

There is a bug in facets/autobuckets.sh file you download. The 2 last scripts execute an aggregation but they aren’t between brackets:

Hi @ksilophone,

Please elaborate your query, so that we can debug the issue that you are facing.

Did you try to run the aggregation pipelines and got the error?
Please share the screenshots for the same.

Please let me know, if you have any questions.

Thanks,
Sonali

After runing the .sh output result only display 2 of the 4 queries

Or If you copy the queries to mongo shell you get the error:

When I looked at the 4 …aggregate() posted by @ksilophone, I noticed that the 2 without the brackets only have 1 stage. I was curious and thought that may be it is a special case and that the aggregate() method is overloaded to accept a single stage as a valid pipeline.

And it looks like it does.

I tried to find documentation indicating this feature but I was not determined enough to find any.

I’m not following you @steevej-1495. Do you mean the square brackets []? Yes, a pipeline with a single stage doesn’t need the square brackets and it’s documented somewhere. If I find it, I’ll let you know.
The square brackets are there to separate stages from options.

Yes I mean square brackets. Being French, may be, but for me brackets are always square. I use parenthesis for () and braces for {}.

Yes, we also distinguish between braces, brackets and parentheses too but it’s generally more understandable when one says brackets :slight_smile:

Here’s the excerpt from the documentation:

2 Likes

Hi @ksilophone,

There is definitely a bug in the handout. I will forward it to the concerned team for correction.

When you run the autoBuckets.sh, the two outputs you see corresponds to the last two pipelines. Please check the screenshot below:

The first two pipelines do not work here because we separately import companies_dataset.companies collection and it is not a part of startups db.

In the screenshot of autoBuckets.sh file following correction is needed:

  1. You need to import the companies_dataset.companies collection to the mongo instance.
  2. Replace the startups in first two pipelines (As underlined in the above screenshot) with companies_dataset. Refer to the below screenshot:

Then try to run the autoBuckets.sh.

Please let me know, if you have any questions

So there is a bug but not the one reported below

I runned on robo3t shell and didn’t work. I’ve just executed on mongo shell and runned correctly:

Is a bug on robo3t shell

From the documentation supplied by 007_jb, this is a feature in the mongo shell but not in the Node.js driver. I suspect robo3t shell uses the Node.js driver.