我在Meteor中进行聚合。我想要做的是制作一个列表,列出文章标题中出现的每个单词,并创建一个包含标题中包含该单词的所有文章的数组。当我测试它时,我得到MongoError: invalid operator '$split'
以下是代码:
Meteor.publish("topics", function () {
// Remember, ReactiveAggregate doesn't return anything
ReactiveAggregate(this, Articles, [
{
$project: {
topic: { $split: ["$title", " "] }
}
},
{
$unwind: {
path: "$topic"
}
},
{
$group: {
_id: "$topic",
articles: { $push: "$$ROOT" }
}
}
], { clientCollection: "clientTopic" });
});