![](/img/trans.png)
[英]How to create an index with ElasticSearch, River and MongoDB?
[英]How to ignore some fields in river mongodb and elasticsearch?
我使用River mongo将mongodb集合绑定到弹性搜索。
这导致mongo集合中的每个字段都将保存在elasticseach索引中。
我想知道如何忽略某些字段,不要让它保存在弹性索引中。
设置mongodb river时,您可以排除某些字段,例如
"mongodb": {
"db": "YourDbName",
"collection": "YourCollectionName",
"options": {
"exclude_fields": "name_of_field_to_be_ignored"
}
},
我从蒙哥河Wiki获得了另一种方法。 通过使用脚本,您可以自定义。但是,应在elasticsearch.yml中将disable script设置为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"
}
}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.