@
plko345 这是我用 fiddler 抓到的包,详细记录了 spark 使用 ESHaghilevelClient 写入数据的 HTTP 报文:
```http
### spark ESOperator 写入
POST http://1.2.3.4:9200/_bulk?timeout=1m HTTP/1.1
Content-Length: 500
Content-Type: application/json
Host: 1.2.3.4:9200
Connection: Keep-Alive
User-Agent: Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_181)
Authorization: Basic ***
{"index":{"_index":"index2","_id":"3"}}
{"content":"这是内容 3","doc_id":3,"headline":"标题 3"}
{"index":{"_index":"index2","_id":"4"}}
{"content":"这是内容 4","doc_id":4,"headline":"标题 4"}
{"index":{"_index":"index1","_id":"1"}}
{"content":"这是内容 1","doc_id":1,"headline":"标题 1"}
{"index":{"_index":"index1","_id":"2"}}
{"content":"这是内容 2","doc_id":2,"headline":"标题 2"}
{"index":{"_index":"index1","_id":"1"}}
{"content":"这是内容 5","doc_id":1,"headline":"标题 5"}
### 响应
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 928
{"took":1731,"errors":false,"items":[{"index":{"_index":"index2","_type":"_doc","_id":"3","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":0,"_primary_term":1,"status":201}},{"index":{"_index":"index2","_type":"_doc","_id":"4","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":1,"_primary_term":1,"status":201}},{"index":{"_index":"index1","_type":"_doc","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":0,"_primary_term":1,"status":201}},{"index":{"_index":"index1","_type":"_doc","_id":"2","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":1,"_primary_term":1,"status":201}},{"index":{"_index":"index1","_type":"_doc","_id":"1","_version":2,"result":"updated","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":2,"_primary_term":1,"status":200}}]}
###
### ESClient 删除 index
DELETE http://12.3.4:9200/index1 HTTP/1.1
Content-Length: 0
Host: 1.2.3.4:9200
Connection: Keep-Alive
User-Agent: Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_181)
Authorization: Basic ***
### 响应
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 21
{"acknowledged":true}
###
```
初步想法是解析 ReqBody,然后根据 index 名称拆分为多个 http 请求发到对应的 ES 集群上,最后响应全部结果给客户端。
但是响应的报文格式应该是无法兼容 ESHighLevelClient 。。。