在 mongodb 中使用文本搜索索引进行多输入和多排除

multiple input and multiple exclusion using text search index in mongodb

我在我的 mongoDb.in 中收集了食谱,我已经创建了关于成分的文本搜索索引。这样我就可以根据我 have.result 应该至少有我通过的配料的配料来搜索食谱。 这是我的 mongodb 查询

中的示例
db.RecipeCollection.find({$text:{$search: "\"potato\" \"tomato\""}},{ score: { $meta: "textScore" } },{_id:0,ingredients:1,num_ingredients:1}).sort( { score:
 $meta: "textScore" },num_ingredients:1 } ).limit(20).pretty()

但问题是我想通过 REST 传递成分,我如何在调用 api.

时传递像 {$text:{$search: "\"potato\" \"tomato\""} 这样的参数
recipes.find({ $text: { $search: req.params.ingredients,$language:"en" } }
            ,{ score: { $meta: "textScore" } }
            ,{_id :0,name:1,ingredients:1,url:1,image:1,num_ingredients:1})
            .sort({score: { $meta: "textScore" },num_ingredients:1})
            .limit(req.params.limit);

我看过这个问题 但我没有足够的声誉来写评论并在那里提问。甚至没有显示我如何传递多个参数。

能否传入一个JSON数组:

{$text: {$search: [ "potato",  "tomato" ] } }