将MongoDB自动连接到ElasticSearch

首先,说到全文搜索,ElasticSearch是个不错的选择。
MongoDB和ElasticSearch有一些相似之处。尤其是在文档格式方面,从MongoDB到ElasticSearch的自动同步也相对容易。
有一些自动同步工具如mongo-connector、monstache等可用。

# MongoDB和ElasticSearch的对比

image.png

这张图是来自db-engines的。
网址:https://db-engines.com/en/system/Elasticsearch%3BMongoDB

自动连携工具

1. MongoDB 连接器

URL链接:https://github.com/yougov/mongo-connector
编程语言:Python 3.4+
MongoDB支持版本:3.4、3.6。

MongoDB的描述:
请查看以下链接:https://github.com/yougov/mongo-connector/wiki/Usage%20with%20MongoDB

2. 小胡子

这是一个可以实时同步的工具。

image.png

細微的参数可以在以下网页找到:
https://rwynn.github.io/monstache-site/config/

特别是文档的大小由elasticsearch-max-bytes参数控制,默认为8MB。如果文档大小超过8MB,将无法同步,需要注意。

3. 节点-蒙戴维亚-Elasticsearch连接器

链接: https://github.com/zhr85210078/node-mongodb-es-connector

image.png

图表位于以下位置:
https://github.com/zhr85210078/node-mongodb-es-connector/blob/master/test/img/structure.jpg

目前所使用的版本号如下:
elasticsearch: v6.1.2
mongodb: v3.6.2
Nodejs: v8.9.3

4. Logstash 徽章+实时数据提取工具

参考文章:将MongoDB数据同步到Elasticsearch的Logstash插件和Logstash配置文件
https://medium.com/@shukla.devbrat1993/logstash-plug-in-and-logstash-configuration-to-sync-mongodb-data-into-elastic-search-400d88e6a180

5. 那个

如果只想将必要的数据投入到ElasticSearch中,或者想要修改索引的内容,当有新的数据、更新或删除时,可以使用ElasticSearch客户端将数据投入到ElasticSearch中。

以上

bannerAds