且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过一个API调用将多个文档发送到Elastic

更新时间:2021-11-04 06:45:32

谢谢@JinLee和@NishantSaini都对我的帮助.我想记录一下我的所作所为.

Thanks, both of you @JinLee and @NishantSaini for helping me. I want to document what I did.

首先,添加/_ bulk 端点.因此,API调用现在为: POST http://localhost:9200/myindex/mytype/_bulk .

First, add /_bulk endpoint. So the API call is now: POST http://localhost:9200/myindex/mytype/_bulk.

现在将 Content-Type 标头设置为 application/x-ndjson

然后身体必须是这样的:

Then the body must be like this:

{"index":{}}
{"message":"message1"}
{"index":{}}
{"message":"message2"}

现在一切正常!