【问题标题】:How to sync mongoose and remote elasticsearch如何同步猫鼬和远程弹性搜索
【发布时间】:2016-09-15 12:10:09
【问题描述】:

我正在使用弹性搜索的 mongoosastic 插件......当启动服务器时,我得到:

Server started
Mapping created
{ acknowledged: true }
Indexed 298 documents

Elasticsearch 创建索引但不同步文档

这是我连接到远程主机的方式:

schema.plugin(mongoosastic, {
    hosts: [
        'MY IP:9200'
    ]
});

有人知道什么会引起问题吗?当我在本地使用它时,一切正常......

我也在使用 Elasticsearch v2.3

【问题讨论】:

  • 为什么说服务器输出“Indexed 298 documents”时文档没有同步?
  • 因为我在弹性服务器上找不到该文档。它创建索引但不添加文档...我发现了问题,看起来 mongoosastic 不适用于最新版本的 Elasticsearch 服务器。

标签: node.js mongodb elasticsearch mongoosastic


【解决方案1】:

您应该在代码中的某处调用 synchronize()

var myDocument = mongoose.model('Document');

myDocument.synchronize();

您可以在mongoosasticdocumentation page中找到如何控制同步文档的数量

【讨论】:

    猜你喜欢
    • 2017-01-07
    • 1970-01-01
    • 2017-02-01
    • 1970-01-01
    • 2015-08-10
    • 2014-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多