[英]How to index(elasticsearch) a specific collection of a specific db of mongodb using transporter?
I want to index only specific mongodb collection in elastic search using transporter. 我只想在使用运输工具的弹性搜索中为特定的mongodb集合编制索引。 Mongodb server has multiple databases having multiple collections.
Mongodb服务器具有多个具有多个集合的数据库。 I dont want to index entire database.
我不想索引整个数据库。
If you only want to copy documents in the my_instance collection, use the namespace filter in the pipeline, ie 如果只想复制my_instance集合中的文档,请在管道中使用名称空间过滤器,即
var source = mongodb({
"uri": "mongodb://172.31.38.157:27017/STOREDB",
"timeout": "30s",
"read_preference": "Primary"
})
var sink = elasticsearch({
"uri": "http://172.31.38.157:9200/INDEX_NAME"
})
t.Source("source", source, "/^my_instance$").Save("sink", sink, "/.*/")
Additionally if you want only specific data from selected collections, the collection_filters setting gets converted to a mongodb query. 另外,如果仅希望来自选定集合的特定数据,则collection_filters设置将转换为mongodb查询。 The commented out example below would only include documents where the i field had a value greater than 10.
以下注释掉的示例仅包含i字段的值大于10的文档。
var source = mongodb({
"uri": "mongodb://127.0.0.1:27017/test"
// "timeout": "30s",
// "tail": false,
// "ssl": false,
// "cacerts": ["/path/to/cert.pem"],
// "wc": 1,
// "fsync": false,
// "bulk": false,
// "collection_filters": "{\"foo\": {\"i\": {\"$gt\": 10}}}"
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.