In order to filter out only the recipes, which are relevant, we need to have a predicate object. In our case searchPredicate variable has the predicate. The search predicate has two properties: $ meaning search over any property, and category meaning search only over category property of the recipe documents. For better understanding what is going on, we have included the predicate object as debug information.
Once we have a predicate object, we can use the Array.$filter() function to narrow down our selection.