MongoError:无效的运算符'$ split'

时间:2017-07-19 21:51:06

标签: mongodb meteor aggregation-framework

我在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" });
});

0 个答案:

没有答案