Hello os community,
I’m trying to understand if it’s possible to create a RestHandler with a custom plugin that stream indices documents directly to the response handler as json/csv.
Unfortunately there is no documentation about this kind of behaviour and after multiple blind test I’m thinking it’s not possibile at all.
However the provided code show the existence of the method bytesOutput
that return a BytesStreamOutput
that maybe is usefull for the job.
public class ExportRestHandler extends BaseRestHandler {
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
return channel -> {
final BytesStreamOutput streamOutput = channel.bytesOutput();
while(true) {
streamOutput.write(...);
}
};
}
}
But I can’t make it work.
Can somebody provide a simple example that can show how correctly implement the streaming feature (always if it’s tecnically possible by the framework).
Thanks in advance for the help