我的要求很簡單,我需要在 ES 中使用給定 ID 索引檔案,在開發工具中,我可以通過在路徑引數中傳遞 idPUT my-index-000001/_doc/1?來做到這一點,當我嘗試使用 nodejs API通過傳遞_id...我得到如果我也嘗試使用開發工具,該錯誤mapper_parsing_exception: [mapper_parsing_exception] Reason: Field [_id] is a metadata field and cannot be added inside a document. Use the index API request parameters.同樣適用,所以我如何設定一個檔案,_id注意這樣做以便在parent:child同一個索引中設定關系,如此處所述
uj5u.com熱心網友回復:
欄位 [_id] 是元資料欄位,不能添加到檔案中。
如果您看到上述錯誤訊息,則清楚地表明您無法傳遞_id到您的檔案正文。
您需要提供id如下所示的外部檔案正文(這只是示例代碼,因為您沒有提供示例代碼,不確定您如何索引檔案):
client.index({
index: 'blog',
id: '1',
type: 'posts',
body: {
"PostName": "Integrating Elasticsearch Into Your Node.js Application",
"PostType": "Tutorial",
"PostBody": "This is the text of our tutorial about using Elasticsearch in your Node.js application.",
}
}, function(err, resp, status) {
console.log(resp);
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/485201.html
標籤:弹性搜索
