Management is concerned about customer complaints regarding cleanliness. You have been instructed to produce a report on properties where more than 50% of the reviews for that property report a low cleanliness score (for example, 3 or less).
When conducting queries of any type, it's important to be aware of the database document structure. In this case, we need to examine the properties collection. Using MongoDB Compass, all you need to do is to connect to the database and select the booksomeplace database, as well as the properties collection. In the list view, you can click on the reviews field to get an idea of the structure, as shown here:
As you can see, reviews are represented as embedded arrays. Following the logic presented in the earlier sub-section in this chapter, your first thought might be to construct a query document such as this:Â {"reviews.cleanliness":{$lt:3}}:
This is not exactly the information we are...