我已经按照在线文档使用 River 插件将数据从 mongodb 复制到 elasticsearch。
我的 Elasticseach 版本是 1.4.2 我的 MongoDB 版本是 2.6.6
我已经将我的 mongodb 设置为作为副本集运行。我已经安装了以下最新插件:
bin/plugin --install com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.5
bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.4.1
然后我启动了 elasticsearch 并使用以下命令从 mongodb 数据库创建一个新索引
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{
"type": "mongodb",
"mongodb": {
"db": "MPTEST",
"collection": "datasets",
"gridfs": false
},
"index": {
"name": "mappr",
"type": "datasets"
}
}'
之后,我可以在我的 elasticsearch 控制台中看到以下日志消息:
[2014-12-20 20:49:34,785][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] MongoDB River Plugin - version[2.0.5] - hash[c11c5ae] - time[2014-12-18T12:08:22Z]
[2014-12-20 20:49:34,786][INFO ][river.mongodb.util ] setRiverStatus called with mongodb - RUNNING
[2014-12-20 20:49:34,788][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] River mongodb startup pending
[2014-12-20 20:49:34,819][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] Starting river mongodb
[2014-12-20 20:49:34,820][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] MongoDB options: secondaryreadpreference [false], drop_collection [false], include_collection [], throttlesize [5000], gridfs [false], filter [null], db [MPTEST], collection [datasets], script [null], indexing to [mappr]/[datasets]
[2014-12-20 20:49:34,838][INFO ][cluster.metadata ] [Mantra] [mappr] creating index, cause [api], shards [5]/[1], mappings []
[2014-12-20 20:49:34,949][INFO ][cluster.metadata ] [Mantra] [_river] update_mapping [mongodb] (dynamic)
[2014-12-20 20:49:35,006][INFO ][river.mongodb ] [Mantra] Creating MongoClient for [[localhost:27017]]
现在我的问题是,此时mongodb中存在的文档不是复制到elasticsearch吗?如果不是,那么当我做一个 mongorestore 来填充我在 mongo 中的集合时,这些文档会被复制过来吗?如果仍然没有,那么我该如何批量复制数据?还是我错过了无法复制数据的东西?