2014-03-13 56 views
1

我已經安裝了一個彈性搜索河流連接mongodb和elasticsearch(使用this插件)。我爲mongodb定義了特定的模式,併爲elasticsearch定義了特定的映射。從彈性搜索河流輸入中排除mongodb字段

我找不到任何有關如何從mongodb中排除字段的信息。我能看到的最接近可行的方法是將這些字段的elasticsearch映射修改爲store:no,index:not_analyzed,include_in_all:false

我仍然不清楚使用上述解決方案是否完全避免了任何處理,因爲理論上所有json提交都存儲在_source中。

任何人對此有任何建議?

回答

2

是的,你可以做mongo-river.you需要指定排除在河字段映射..我已經連接的樣本代碼..看看..

curl -XPUT 'http://IP:9200/_river/mongodb/_meta' -d '{ 
"type": "mongodb", 
"mongodb": { 
    "db": "DATABASE_NAME", 
    "collection": "COLLECTION", 
    "gridfs": true 
}, "options": { 
    "secondary_read_preference" : true, 
    "drop_collection": ${mongo.drop.collection}, 
    "exclude_fields": ${mongo.exclude.fields}, 
    "include_fields": ${mongo.include.fields}, 
    "include_collection": ${mongo.include.collection}, 
    "import_all_collections": ${mongo.import.all.collections}, 
    "initial_timestamp": { 
    "script_type": ${mongo.initial.timestamp.script.type}, 
    "script": ${mongo.initial.timestamp.script} 
    }, 
    "skip_initial_import" : ${mongo.skip.initial.import}, 
    "store_statistics" : ${mongo.store.statistics}, 
}, 

"index": { 
    "name": "ES_INDEX_NAME", 
    "type": "ES_TYPE_NAME" 
} 
}' 

更多信息,請參閱: https://github.com/richardwilly98/elasticsearch-river-mongodb/wiki

HOpe它幫助..!

+0

我嘗試過從河流中排除字段,但顯然他們仍然保存在_source中。所以基本上回到原點。 – lesingerouge