const searchField = "$data.product";
But If I try to use concatenation and add a variable name const searchField = "$data." + key;
then it fails with the error:
MongoServerError: PlanExecutor error during aggregation:: caused by:: $regexMatch needs ‘input’ to be of type string
I have tried using template format but it also does not work $data.${key}