Problem solving Chapter 4 Lab 2: Querying Arrays and Sub-Documents

Dear all,

I had no problems with the tasks up to this point. I saw several other topics addressing this Lab, but none seems to relate to the most recent status of the sample_training.inspections collection.

The Question is:
How many inspections from the sample_training.inspections collection were conducted in the city of NEW YORK?

my current attemps (2/3):

  1. my first guess was to match the nested document’s field for "NEW YORK" which returned 18280 which was a wrong anwer.
  2. then I thought, maybe some are spelled differently and did a "$regex" comparison for "[Nn][Ee][Ww] [Yy][Oo][Rr][Kk]" which brought up 5 cities with "New York" and another 24 with "WEST NEW YORK". I am not from the US but googled up that West New York is a different town. So adding a query to remove "WEST NEW YORK"gave me 18285 which was wrong as well.

I am now stuck at my 3rd attempt and have no further idea how to narrow this down. Going for the zips seems incorrect, as already some "NEW YORK" cities have different zips. In addition older topics from end 2020 seem to get 18279 "NEW YORK" (1 less) and 5 "New York" which would sum up to 18284.

May anybody point me towards the solution, please?

Hi @Martin_Halwachs, welcome to the community.
Your first attempt was correct and was very close to the answer, but it seems like some of the documents from your “inspections” collection have gone sideways. I would recommend you to delete all the sample data from your Cluster and please load a fresh copy of sample data from the menu.

In case, it doesn’t work or if you have any doubts, please feel free to reach out to us.

Thanks. Regards.
Sourabh Bagrecha,
Curriculum Services Engineer


Hi @SourabhBagrecha, thank you that worked. I could have figured that out myself ^^’

I deleted all sample_* databases and clicked on “Load Sample Data” in my cluster. On the first attempt I had some memory issue (not enough space), even though I just had a single database with a small custom collection of 72KB left. After some minutes I retried and sample data loaded successfully.