[NOTICE] Chapter 3: Lab - $group and Accumulators

Hi,

Please note that other awards like BAFTA or Golden Globe are also in the awards key, so only filtering by the word “Won” would not return the expect result. I would suggest a regular expression that matches the strings: “Won x Oscar” and “Won x Oscars”, where x is a number.

José Carlos

2 Likes

I am not able to a text search on the awards field. It says an index is needed. When I tried creating an index in the awards field, get an error saying no access. Any other way of searching via regular expression.

Hi,

Indeed you should use a regular expression. You could just do a single $match like this:

$match: {field: / your regular expression /}

This thread may be helpful as well:

José Carlos