在
client.bulk()拨打电话之前,您首先需要
client.indices.putMapping()拨打另一个这样的电话,以便为您要通过该
bulk电话发送的数据保存正确的映射:
client.indices.putMapping({ "index": "testindex", "type": "testtype", "body": { "testtype": { "properties": { "your_int_field": { "type": "integer" }, "your_string_field": { "type": "string" }, "your_double_field": { "type": "double" }, // your other fields } } }}, function (err, response) { // from this point on, if you don't get any error, you may call bulk.});请记住,所有这些调用是异步的,所以一定要小心,只叫
bulk一次,
putMapping已成功返回。



