【发布时间】:2015-04-23 15:19:28
【问题描述】:
我使用 River mongo 将 mongodb 集合绑定到弹性搜索。
这导致 mongo 集合中的每个字段都将保存在 elasticseach 索引中。
我想知道如何忽略某些字段,不要让它保存在弹性索引中。
【问题讨论】:
标签: elasticsearch
我使用 River mongo 将 mongodb 集合绑定到弹性搜索。
这导致 mongo 集合中的每个字段都将保存在 elasticseach 索引中。
我想知道如何忽略某些字段,不要让它保存在弹性索引中。
【问题讨论】:
标签: elasticsearch
设置mongodb river时,可以排除某些字段,例如
"mongodb": {
"db": "YourDbName",
"collection": "YourCollectionName",
"options": {
"exclude_fields": "name_of_field_to_be_ignored"
}
},
【讨论】:
我从 River mongo wiki 获得了另一种方法。通过使用脚本,您可以自定义..但是,您应该在 elasticsearch.yml 中将禁用脚本设置为 false。
https://github.com/richardwilly98/elasticsearch-river-mongodb/wiki
$ curl -XPUT "localhost:9200/_river/mongoscriptfilter/_meta" -d'
{
"type": "mongodb",
"mongodb": {
"db": "testmongo",
"collection": "documents",
"script": "ctx.document.title = ctx.document.title_from_mongo; delete ctx.document.title_from_mongo;"
},
"index": {
"name": "testmongo",
"type": "documents"
}
}'
【讨论】: