M001 Chapter 2, Quiz Data Explorer. Query not working right

In the quiz for Data Explorer, we are asked the following…

In the sample_training.trips collection a person with birth year 1961 took a trip that started at “Howard St & Centre St”. What was the end station name for that trip?

If I run the following query in the data explorer…

{"birth year": "1961",  "start station name": "Howard St & Centre St"}

I get 0 records returned. So I trimmed it down to see what works and what doesn’t.

{"start station name": "Howard St & Centre St"}

I get 1-20 of many.

{"birth year": "1961"}

I get 0 records returned.

As I understand the syntax of the query and the field name from the JSON document, I THINK I have that query correct.

What am I missing?

Hi @David_Hostetler,

This data set doesn’t have any documents with birth year as the string value "1961".

A more natural way to store birth year would be as a numeric value. Try adjusting your query to match numeric instead of string values.

Regards,
Stennie

1 Like

Since this is the first query quiz / lab. I am simply following instruction here. I don’t recall anything from the lecture about any differences between string and numeric values.

I do see the field of “birth year” and the value of “1961”.

How would I adjust my query to get the desired result?

Sorry for what probably seems a stupid question. I am trying to grasp the material fully before moving forward…

I just rewatched the lecture prior to this quiz, and there is no mention whatsoever of different data types, nor any variations on how to query for them. Simply the {“field”: “value”, “field2”: “value”} description, in this case {“state”: “NY”, “city”: “ALBANY”}

Odds are better than good this information is presented in a later lecture, but as of yet, no dice.

Hi @David_Hostetler,

I was trying to give a hint rather than an explicit answer, but it sounds like data types may not have been explained well yet.

If you search exactly as per your screenshot, the result should match.

Click for a spoiler:

// String values are quoted
{"birth year": "1961"}

// Numeric values are not quoted
{"birth year": 1961}

Regards,
Stennie

1 Like

No worries at all. Very grateful for the help. It just seems like the lab exercises / quizzes would cover material already covered.

1 Like

It just seems like the lab exercises / quizzes would cover material already covered.

Hi @David_Hostetler,

I agree – exercises and assessments should be based on prior learning activities or include references for further reading to gain presumed knowledge.

I’m not familiar with the current M001 lectures, but here are some suggested references for data types:

It is convenient to think of MongoDB documents as JSON-like, but the actual implementation uses a binary format called BSON (Binary JSON) which can represent a superset of JSON data types.

Regards,
Stennie

2 Likes

I have just wasted a significant amount of time wondering why my syntax doesn’t work and have now discovered here that I have exactly the same issue as David.
Why does this course have quiz questions that assume knowledge that hasn’t been given in the lecture?
Please can the lecture be amended or the question changed to let people know they need to look into data types?

Welcome to the MongoDB Community Forums @Graham_Rhodes !

I’m not sure why there wouldn’t be more elaboration on data types prior to the quiz content, but strings versus numeric values are definitely distinct. I’ll pass this feedback onto the curriculum team for improvement.

Regards,
Stennie