We´re able to access the RequestBody sent by the client for searches - pretty easy.
But is there a way to have this for BulkRequests too? Or in other words: I need access to the _bulk payloads compiled/send by the java-rest-client and save them into files for reasons.
My Code:
BulkRequest request = new BulkRequest();
request.add(new IndexRequest("posts").id("1")
.source(XContentType.JSON,"foo", "ba1"));
request.add(new IndexRequest("posts").id("2")
.source(XContentType.JSON,"foo", "bar2"));
request.add(new IndexRequest("posts").id("3")
.source(XContentType.JSON,"foo", "bar3"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamStreamOutput osso = new OutputStreamStreamOutput(baos);
request.writeTo(osso);
String requestAsString = baos.toString("UTF-8");
The Output:
���� ����posts _doc1
{"foo":"ba1"} �������� �������� ����posts _doc2 {"foo":"bar2"} �������� �������� ����posts _doc3 {"foo":"bar3"} �������� ��������
Expected/Desired Output:
{ "index" : { "_index" : "posts", "_id" : "1" } }
{ "foo" : "bar1" }
{ "index" : { "_index" : "posts", "_id" : "2" } }
{ "foo" : "bar2" }
{ "index" : { "_index" : "posts", "_id" : "3" } }
{ "foo" : "bar3" }
Anyone eager to help? Thanks in advance!