XContentBuilder builder = XContentFactory.contentBuilder(type);
builder.startObject();
builder.field("field1", "value1");
builder.rawField("_source", XContentFactory.contentBuilder(type).startObject().field("s_field", "s_value").endObject().bytes());
builder.field("field2", "value2");
builder.rawField("payload_i", new BytesArray(Long.toString(1)));
builder.field("field3", "value3");
builder.rawField("payload_d", new BytesArray(Double.toString(1.1)));
builder.field("field4", "value4");
builder.rawField("payload_s", new BytesArray("test"));
builder.field("field5", "value5");