是的,github上有一条新的MongoDB河:
https://github.com/richardwilly98/elasticsearch-river-mongodb
如需进一步说明,您可以按照以下步骤操作:
第 1 步:-安装
ES_HOME/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/1.4.0
ES_HOME/bin/plugin -install richardwilly98/elasticsearch-river-mongodb/1.4.0
第2步: -Restart Elasticsearch
ES_HOME/bin/service/elasticsearch restart
Step.3: - 在 mongodb 中启用副本集
转到mongod.conf并添加行
replSet=rs0
保存并退出
重启 mongod
Step.4 :-testmongo
告诉elasticsearch通过在终端中发出以下命令来索引数据库中的“person”集合
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{
"type": "mongodb",
"mongodb": {
"db": "testmongo",
"collection": "person"
},
"index": {
"name": "mongoindex",
"type": "person"
}
}'
Step.5: -通过mongo终端向mongodb添加一些数据
use testmongo
var p = {firstName: "John", lastName: "Doe"}
db.person.save(p)
Step.6: -使用此命令搜索数据
curl -XGET 'http://localhost:9200/mongoindex/_search?q=firstName:John'
笔记:
DELETE /_river
DELETE/_mongoindex
再次运行此命令,
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{
"type": "mongodb",
"mongodb": {
"db": "testmongo",
"collection": "person"
},
"index": {
"name": "mongoindex",
"type": "person"
}
}'
Step.7: -查看总部插件
在mongoindex
中,您将获得您的数据。