简体   繁体   English

如何使用传输器为mongodb的特定数据库的特定集合建立索引(elasticsearch)?

[英]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.

相关问题 如何使用mongo-connector仅对特定mongodb数据库中的特定集合进行索引(elasticsearch)。 - how to index (elasticsearch) only specific collection in a specific mongodb database using mongo-connector. 如何在 Atlas mongoDB 中创建特定于集合的搜索索引? - How to create a collection specific search index in Atlas mongoDB? 如何使用MongoDB Shell从MongoDB集合中获取特定字段? - How to get specific field from MongoDB collection using MongoDB shell? 如何使用Spring数据将文档插入mongodb中的特定集合? - How to insert document to specific collection in mongodb using spring data? 如何使用 mongodb 以特定密钥加入多个集合? - How to join for multiple collection with specific key using mongodb? 使用MongoDB和Mongoose的MapReduce特定集合 - MapReduce specific Collection using MongoDB & Mongoose 如何将节点 API 连接到本地机器上的特定 mongoDB 数据库/集合 - How to connect node API to specific mongoDB db / collection on my local machine 如何从Django中的mongodb获取特定集合 - how to fetch specific collection from mongodb in django 如何在mongodb中计算集合中的特定元素 - How to count a specific element in a collection in mongodb 如何禁用特定集合的MongoDB缓存? - How to disable MongoDB cache for specific collection?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM