【问题标题】:Search multiple collections with mongoosastic使用 mongoosastic 搜索多个集合
【发布时间】:2020-01-16 11:59:53
【问题描述】:

在 Node.js 应用程序中,我使用 Mongoosastic 从 ElasticSearch 检索数据:

Article.search({
  "match_all": {}
}, function (err, results) {
  console.log(results.hits.hits);
  Post.search({
    "match_all": {}
  }, function (err, results) {
    console.log(results.hits.hits);
    return next();
  });
});

在这里,我发出两个请求以从两个不同的集合中检索数据。我想知道这是否是个好方法?

是否可以在一个请求中从两个集合(或多个集合)中搜索数据? (例如使用多搜索 API,但使用 Mongoosastic)。

谢谢。

【问题讨论】:

    标签: javascript node.js elasticsearch mongoose mongoosastic


    【解决方案1】:

    看起来我们不能用 Mongoosastic 做到这一点。

    实际上,该项目在 GitHub 页面中将自己定义为:

    一个可以自动索引你的模型的猫鼬插件 弹性搜索

    所以我用它来定义我的索引,但要进行搜索查询,它可以在官方 javascript 客户端上正常工作。

    这里有同样的问题:https://github.com/mongoosastic/mongoosastic/issues/41

    【讨论】:

      猜你喜欢
      • 2014-07-31
      • 2021-04-17
      • 1970-01-01
      • 2020-05-06
      • 1970-01-01
      • 1970-01-01
      • 2019-08-02
      • 2013-12-02
      • 1970-01-01
      相关资源
      最近更新 更多