Ticket: Connection Fix

I was having trouble with passing the Ticket: Connection lab and the initial unit test they ask you to perform due to a problem with the handout/sample dataset they ask you to load in the Atlas cluster. The unit test/validation code for Connection expects 23539 movies in the collection but if you load the sample dataset from the Altas UI, you only get 23531 movies. I found the correct dataset to be part of the notes of the Setting up Atlas Lecture. I’ll include a copy of the download link here. You’ll need to use the mongorestore command to load the data onto your own cluster. I would suggest deleting the sample dataset from your cluster before restoring in order to get the correct number of movies, but it may be the case the restore will just add the 8 missing movies (I haven’t tried restoring on the Altas sample dataset).

Your mongorestore command should like something like this:
mongorestore --host mflix-shard-0/mflix-shard-00-00-#####.mongodb.net:27017,mflix-shard-00-01-#####.mongodb.net:27017,mflix-shard-00-02-#####.mongodb.net:27017 --ssl --username m220student --password m220password --authenticationDatabase admin --gzip --archive=sample.archive.gz.

Note: Make sure you do this in the same directory that you downloaded the sample.archive.gz file.
Note: Your hostname may differ from the one above if you created your cluster on your local machine instead of Atlas. For Atlas clusters the hostname above is similar but you will need to replace the #####. Or you can go to the Command Line Tools section of the Atlas cluster UI for your cluster and copy the mongorestore command from there and appending --gzip --archive=sample.archive.gz to the end of it.
Note: Your username, and password may differ if you used something different for it upon cluster setup, I’m going by the class setup instructions.

I hope this helps you out while the MongoDB team fixes their inconsistencies with the mflix handout and the sample dataset on Atlas.

Edit: As I was doing the next Ticket labs for the course I noticed the dataset I’ve linked here does not have a text index that you need to perform text queries with. After some testing and looking if the Atlas cluster had the index, here’s what you need to do to create the index pass future Tickets that assumed you have the index.

  1. Connect to your cluster via the mongo shell.
  2. Switch to the sample_mflix database with the command use sample_mflix.
  3. Create the text index with the command db.movies.createIndex({cast: "text", fullplot: "text", genres: "text", title: "text"}, {sparse: true}).

This should create the text index needed for text queries in passing future Tickets.

Note: As of this posting you can only create text indexes through the mongo shell and not through Compass.

@Tommy_Wong the download link you provided for the new sample dataset downloads a sample.archive file and not a .gz file.

@David_Nakabaale does your OS hide file extensions? And what OS are you on? When you click the link you should get a download prompt with the default file name as “sampledata.archive.gz” or “sampledata.archive” if the extension is hidden or if on Windows. If on MacOS you should also see a another field in your download prompt that says “Format” and by default it should say “GZip archive”. If on Windows, instead of the “Format” field you should have “Save as type” and by default it should be “GZ File”. If this is the case it should still be fine.

If you are still getting an just an archive file, perhaps trying renaming it and changing the extension to be “.gz” to get the correct file, this may pop up a warning.

Thanks for reporting this. We are aware about the issue and working on it to resolve it ASAP.


@Tommy_Wong it seems to be a safari issue. I’m running macOS and I was able to download the file with its extension with chrome, and I the new dataset loaded.
Thank you for your post.

Same trouble when passing the ticket connection.
1 test failed, 3 passed, 39 deselected in 14 second
assert 23539 == 23531

Please download the latest handouts with the updated tests. Also, make sure the dataset you loaded has count 23531 in movies collection. (sample_mflix db)