Format of `awards` field in `db.movies`

So I am working on the Chapter 3 - Lab 1 and the question statement provides a hint as follows

HINT - All movies in the collection that won an Oscar begin with a string resembling one of the following in their awards field

Won 13 Oscars
Won 1 Oscar

So I decided to first check out the awards fields in the mongo shell with the following pipeline:

var pipeline = [
	{
		$match:{
			awards: { $exists: true }
		}
	},
	{
		$project: {
			_id: 0,
			awards: 1
		}
	}
]

This gives me the following output:

{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "2 wins." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "1 nomination." }
{ "awards" : "1 win." }
{ "awards" : "2 nominations." }
{ "awards" : "1 win." }
{ "awards" : "1 win." }
{ "awards" : "2 wins." }
{ "awards" : "1 win & 1 nomination." }

Does this mean that the awards field has a different format as compared to the HINT provided for the lab?

P.S.

I ran the following query to see if any documents had Oscars in their awards string

> db.movies.find({awards: "Oscars"}).count()
> 0

I am highly confused about the format of the awards string to find the number of Oscars won by the movie. Do the wins and nominations in the awards strings i got signify the stats for Oscars?

This part of the lab is a pattern matching or regex exercise and the hint is accurate. The output you showed doesn’t match the pattern in the hint.

I have tried the query

db.movies.find({awards: "Won 1 Oscar"})

It does not show any documents that match with that awards query

Is it possible that the format of awards has changed since the writing of the Lab description?

Remember you’re looking for a pattern… so there could be other words after “Won 1 Oscar”, which means that an equality check would most likely not yield results.

1 Like

@007_jb Thank you so much for your reply. I was just not checking properly. I see what you mean now

:slightly_smiling_face: :+1: