5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MongoDB⇒ElasticSearchへの自動連携

Last updated at Posted at 2019-08-31

#はじめに
全文検索といえば、ElasticSearchはよいですね。
MongoDBとElasticSearchは似ている部分があります。特にドキュメント形式でMongoDB⇒ElasticSearchに自動同期もしやすいです。
mongo-connector、monstacheなどの自動同期のツールがあります。

#MongoDBとElasticSearchの比較

image.png

図はdb-enginesからのものです。
https://db-engines.com/en/system/Elasticsearch%3BMongoDB

#自動連携ツール

1. mongo-connector

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. monstache

リアルタイムで同期できるツールです。

URL: https://rwynn.github.io/monstache-site/
GitHub URL: https://github.com/rwynn/monstache
言語: Go
MongoDBバージョン:
image.png

細かいパラメータは下記のページにあります。
https://rwynn.github.io/monstache-site/config/

とくにドキュメントのサイズは、elasticsearch-max-bytesパラメータで制御され、デフォルトは8MBです。ドキュメントのサイズを8MB超えると同期されないので要注意です。

3. node-mongodb-es-connector

URL: 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

参考記事:Logstash Plugin and Logstash configuration to sync MongoDB data Into elastic-search
https://medium.com/@shukla.devbrat1993/logstash-plug-in-and-logstash-configuration-to-sync-mongodb-data-into-elastic-search-400d88e6a180

5. そのた

必要なデータのみElasticSearchに投入したい場合、またはIndexの中身を加工したい場合は、データ新規、更新、削除のとき、ElasticSearch Clientを利用してElasticSearchに投入してもよいです。

以上

5
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?